?
Solved

How do you display rows from a cfoutput query 20 rows at a time with clickable link to see next 20

Posted on 2009-04-05
5
Medium Priority
?
381 Views
Last Modified: 2013-12-16
How do you display rows from a cfoutput query 20 rows at a time with clickable link to see next 20 when their are over 200 recs. The query is sql 2005 and CF8 to display. I use a standard table to display the recs.

0
Comment
Question by:LeadCo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Assisted Solution

by:duncancumming
duncancumming earned 400 total points
ID: 24074825
Firstly, take a look at both the following:
http://paginationcfc.riaforge.org/
http://listpages.riaforge.org/

Secondly, the basic way is to pass a URL parameter for the start row.  Code might be something like this (this is a very basic version but should give you an idea of how to proceed).

<cfparam name="URL.start" default=1>
<cfset Max = 20>	<!--- set this as a variable, allows you to easily change it later --->
 
<cfquery name="getData" ...>
	...
</cfquery>
 
<cfoutput query="getData" startrow="#URL.start#" maxrows="#Max#">
 
</cfoutput>
 
<cfif URL.start - Max GT 1>
<!--- previous pages --->
	<a href="?start=#(URL.start-Max)#">Prev</a>
</cfif>
 
<cfif URL.start + Max LTE getData.RecordCount>
<!--- more pages --->
	<a href="?start=#(URL.start+Max)#">Next</a>
</cfif>

Open in new window

0
 
LVL 27

Accepted Solution

by:
azadisaryev earned 1200 total points
ID: 24074832
if your data is just text and the look of your table is not significant (i.e. you do not have strict requirements on the colors, fonts, etc), then check out <cfgrid> tag - in CF8 it now comes in HTML format. it's a quick way to add paginated query display to your page, but customizing it to look any different from its default look is a true pain...

otherwise... see if these links help you:
http://www.bennadel.com/blog/990-Paginating-Record-Sets-In-ColdFusion-With-One-SQL-Server-Call.htm
http://www.knowmysize.com/blog/index.cfm?mode=entry&entry=A8848275-10B7-AFAB-AE7A1058DEA7D968&dv=recent

(the second one is SQL Server 2005 specific and uses rather complicated stored procedure)

Azadi
0
 
LVL 2

Assisted Solution

by:shariff_pasha
shariff_pasha earned 400 total points
ID: 24074834
hi leadco
replace the filename with the file where u r implementing the pagination and replace the queryname with the query u r using...
<cfparam name="more" default="1">
		<cfif isdefined ("more")>
		<cfset still_more=#more#+20>
		</cfif>
	<cfset i=0>
		<cfoutput query="queryname" startrow="#more#" maxrows="20">
</cfoutput>
<table>
		<tr>
			<td>
				<table width="750">
				<tr>
					<td align="right">
					<cfoutput>
					<cfif #more# is not 1><br>
						<a href="filename.cfm?more=#evaluate(more-20)#"><< Previous 20 Records</a>
					</cfif> 
					</td>
					<td  align="right">
					<cfif #still_more# lte queryname.recordcount>
						<cfif #evaluate(still_more+9)# gt queryname.recordcount>
					<cfoutput>#evaluate(still_more+9)#</cfoutput>
						<cfset next_record_count=#queryname.recordcount# mod 20><br>
						<a href="filename.cfm?more=#still_more#">>> Next #next_record_count# Records</a>
						<cfelse><br>
					<cfoutput>#evaluate(still_more+9)#</cfoutput>
						<a href="filename.cfm?more=#still_more#"> >> Next 20 Records</a>
						</cfif>
					</cfif>
					</cfoutput>
					</td>
			 </tr>
			</table>
		</td>
	 </tr>
	</table>

Open in new window

0
 
LVL 1

Expert Comment

by:Digitalmesh
ID: 24076432
hi leadco,

Just try pagination
see the link

 http://tutorial405.easycfm.com/

Hope this will help you.....
0
 

Author Closing Comment

by:LeadCo
ID: 31566915
Thanks Guys!
0

Featured Post

7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
Suggested Courses
Course of the Month8 days, 4 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question