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>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
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!

Hope this helps

<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>&nbsp;&nbsp; <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>

freshfitz: thank you very much it works great..thanks once again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.