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 :
*****************************************************
<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!