Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coldfusion Pagination in details page. 1

Status
Not open for further replies.
Mar 24, 2010
2
US
Hello All,
Can anyone help me out with this problem.

I have a coldfusion master page which displays the category (Galleries.cfm). When users click on Category link, it goes to the details Page (Gallery_Display.cfm), link by Cat_ID. On the Detail page, there are hundreds of records that I want to break into pages, which display only 20 records/ page.
However, whenever I click on the "NextPage" from second, third...category, it shows only the records from the First Category.

IS there any way to fix this problems?

here is my sample page:
<b><u>
</u></b>
 
Kevin,

something that would be more than usefull here is the code of your page (gallery_display.cfm) ... but based on pure theory here is a sample...

Pagination isn't exactly difficult to do, so i would just recommend having a look at google for more complete FAQs and instructions, but if you need more help... let's see your code :)

Code:
<cfquery name="qQuery" datasource="MyDatasourceName">
	SELECT x, y, z
	FROM tableName
	WHERE cat_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#url.cat_id#">
</cfquery>

<cfparam name="url.page" default="1" />
<cfset myMaxRow = 20 /> <!--- for 20 items per page --->

<cfscript>
	iTotalPages = ceiling(qQuery.recordCount / myMaxRow);
	myStartRow = ((url.page * myMaxRow) - myMaxRow)+1;
</cfscript>

<cfif iTotalPages GT 1>
	<cfoutput><cfloop from="1" to="#iTotalPages#" index="p"><a href="#cgi["script_name"]#?cat_id=#url.cat_id#&page=#p#">#p#</a> |</cfloop></cfoutput>
</cfif>

<cfoutput query="qQuery" startRow="#myStartRow#" MaxRows="#myMaxRow#">
	....
</cfoutput>

<cfif iTotalPages GT 1>
	<cfoutput><cfloop from="1" to="#iTotalPages#" index="p"><a href="#cgi["script_name"]#?cat_id=#url.cat_id#&page=#p#">#p#</a> |</cfloop></cfoutput>
</cfif>

Regards,
B.

We never fail, we just find that the path to succes is never quite what we thought...
 
Always a pleasure

We never fail, we just find that the path to succes is never quite what we thought...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top