| | |
Cold Fusion Display FAQ
Please support our ColdFusion advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2009
Posts: 1
Reputation:
Solved Threads: 0
Hi All,
I am new to this Coldfusion and i am creating a FAQ page.
My Database is MS ACCESS. It is working but with some code error as i am displaying 5 FAQ on first page then next 5 FAQ on the other page and so on. The PROBLEM i am having is lets say my Database has 18 faqs.
it would display
page 1 --- 5 FAQ
page 2 --- 5 FAQ
page 3 --- 5 FAQ
PAGE 4 --- DOESNT SHOW ANY FAQ so the remaining 3 are not retrieved from the database.
I will be very thankful if you guys can please help me with this issue.
Below is the code :
*****************************************************
*****************************************************
Pls help!
I am new to this Coldfusion and i am creating a FAQ page.
My Database is MS ACCESS. It is working but with some code error as i am displaying 5 FAQ on first page then next 5 FAQ on the other page and so on. The PROBLEM i am having is lets say my Database has 18 faqs.
it would display
page 1 --- 5 FAQ
page 2 --- 5 FAQ
page 3 --- 5 FAQ
PAGE 4 --- DOESNT SHOW ANY FAQ so the remaining 3 are not retrieved from the database.
I will be very thankful if you guys can please help me with this issue.
Below is the code :
*****************************************************
coldfusion Syntax (Toggle Plain Text)
<html> <head> <title>Frequently Asked Questions</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="FAQStylesheet.css" rel="stylesheet" type="text/css"> </head> <body> <img src="RMA.JPG" width="960" height="63"> <hr><hr> <H2>FREQUENTLY ASKED QUESTIONS</H2> <hr> <br> <form action="search.cfm" method="post"> <input type="submit" name="Search" value="Search FAQ"> </form> <br><br><br> <cfquery name="getfaq" datasource="faqdatabase"> Select * from qa order by qarefno desc </cfquery> <cfparam name="URL.PageIndex" default="0"> <cfset Recordsperpage=5 > <cfset totalpages=(getfaq.recordcount/recordsperpage)-1> <cfset startrow=(URL.pageindex*recordsperpage)+1> <cfset endrow=(startrow+recordsperpage)-1> <cfoutput> <cfloop query="getfaq" > <cfif currentrow gte startrow> <Strong>Qusetion#getfaq.qarefno# : #getfaq.fquestion#</Strong><br> <Strong>Answer:</Strong> <h4>#getfaq.fanswer#</h4> <br><br><br><br><br> </cfif> <cfif currentrow eq endrow> <cfbreak> </cfif> </cfloop> </cfoutput> <strong> Select Page</strong> <cfloop index="pages" from="0" to="#totalpages#"> <cfoutput> | <cfset displaypgno=pages+1> <cfif URL.pageindex eq pages> <strong>#displaypgno#</strong> <cfelse> <a href="?pageindex=#pages#">#displaypgno#</a> </cfif> | </cfoutput> </cfloop> </body> </html>
*****************************************************
Pls help!
Last edited by peter_budo; 17 Days Ago at 6:39 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)
•
•
Join Date: Sep 2008
Posts: 337
Reputation:
Solved Threads: 27
0
#2 2 Days Ago
Hope this helps
ColdFusion Syntax (Toggle Plain Text)
<html> <head> <title>Frequently Asked Questions</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link href="FAQStylesheet.css" rel="stylesheet" type="text/css"> </head> <body> <img src="RMA.JPG" width="960" height="63"> <hr><hr> <H2>FREQUENTLY ASKED QUESTIONS</H2> <hr> <br> <form action="search.cfm" method="post"> <input type="submit" name="Search" value="Search FAQ"> </form> <br><br><br> <cfquery name="getfaq" datasource="#application.dsn#"> Select * from games order by game desc </cfquery> <cfparam name="URL.PageIndex" default="0"> <cfif IsDefined("Getfaq.RecordCount")> <cfif NOT IsDefined("FORM.CurrentPage")> <cfset variables.CurrentPage = 1> <cfelse> <cfset variables.CurrentPage = FORM.CurrentPage> </cfif> <!--- Calculate the total number of pages. ---> <cfscript> variables.ItemsPerPage = 5; if (Getfaq.RecordCount LT variables.ItemsPerPage) variables.TotalPages = 1; else variables.TotalPages = NumberFormat(GetFaq.RecordCount / variables.ItemsPerPage, 9999); </cfscript> <!--- Since the rounding up doesn't work, if there are items left over for an extra page, add it here. ---> <cfif Getfaq.RecordCount - (variables.TotalPages * 100) GT 0> <cfset variables.TotalPages = variables.TotalPages + 1> </cfif> <!--- Check to make sure the user doesn't try to go beyond the Total number of pages. ---> <cfif variables.CurrentPage GT variables.TotalPages> <cfset variables.CurrentPage = variables.TotalPages> </cfif> <!--- Calculate the Start and End points for the Items Query. ---> <cfscript> variables.Start = (variables.CurrentPage * variables.ItemsPerPage) - 4; variables.End = (variables.CurrentPage * variables.ItemsPerPage); </cfscript> </cfif> <cfif IsDefined("Getfaq.RecordCount")> <script language="JavaScript"> function validateform_gotobreadcrumb (f) { if (f.CurrentPage.value == "") { alert("Please enter a page number before clicking the GO button."); return false; } return true; } function GoToPageN() { if (validateform_gotobreadcrumb(document.viewPage)) document.viewPage.submit(); } function SortList(sortorder) { document.viewPage.SortOrder.value = sortorder; document.viewPage.CurrentPage.value = 1; if (validateform_gotobreadcrumb(document.viewPage)) document.viewPage.submit(); } </script> <cfif variables.TotalPages GT 1> <strong><cfoutput>#Getfaq.RecordCount#</cfoutput> total items found.</strong><br><br> <form action="test.cfm" method="post" name="viewPage"> View Page: <select name="CurrentPage"><cfloop from="1" to="#variables.TotalPages#" index="i"><cfoutput><option value="#i#"<cfif variables.CurrentPage IS i> selected</cfif>>#i#</option></cfoutput></cfloop></select> <strong>of <cfoutput>#variables.TotalPages#</cfoutput></strong> <input type="Button" value="Go" onclick="GoToPageN();"> </form> </cfif> </cfif> <cfoutput> <cfloop query="getfaq" startrow="#variables.Start#" endrow="#variables.End#"> <Strong>Qusetion#getfaq.game# : #getfaq.week#</Strong><br> <Strong>Answer:</Strong> <h4>#getfaq.home_team#</h4> <br><br><br><br><br> <cfif start eq end> <cfbreak> </cfif> </cfloop> </cfoutput> </body>
Last edited by freshfitz; 2 Days Ago at 12:49 am.
![]() |
Similar Threads
- Looking for Cold Fusion Developers (Software Development Job Offers)
- Web Applications Developer (Web Development Job Offers)
- Experience Cold Fusion / PHP / CSS / Javascript Programmer (Post your Resume)
- How to find location of cold fusion database (ColdFusion)
- Cold fusion do not support input param: Help (ColdFusion)
- PHP vs Cold Fusion (PHP)
- [JOB] Senior Cold Fusion Developer, Alexandria, VA (Web Development Job Offers)
- Multi-Domain Hosting - Linux, Windows & Cold Fusion Starting at $3.95/mo! (Web Hosting Deals)
- cold fusion administrative access (ColdFusion)
Other Threads in the ColdFusion Forum
- Previous Thread: Does ColdFusion MX 7 have cfselect bind option?
- Next Thread: Simple? SQL insert problem
| Thread Tools | Search this Thread |






