<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Next - Previous made easy</title>

<!---Links Style--->
<style type="text/css">
a {
text-decoration: none;
font-weight: bold;
color: Blue;
}

a:hover {
text-decoration: underline;
</style>
</head>

<!--- define startrow and maxrows to facilitate 'next N' style browsing --->
<CFPARAM name = "MaxRows" default = "10">
<CFPARAM name = "StartRow" default = "1">

<!--- Query database for information -------->
<CFQUERY name = "GetParks" datasource = "cfdocexamples"
cachedWithin = "#CreateTimeSpan(0, 6, 0, 0)#">
SELECT PARKNAME, REGION, STATE
FROM Parks
ORDER by ParkName, State
</CFQUERY>

<body>

<!--- build HTML table to display query --->
<table>
<tr>
<td colspan = 2>
<b><i>Park Name</i></b>
</td>
<td bgcolor = f0f0f0>
<b><i>Region</i></b>
</td>
<td bgcolor = f0f0f0>
<b><i>State</i></b>
</td>
</tr>
<!--- Output query, define startrow and maxrows.
Use query variable CurrentCount to track the row you are displaying. --->
<CFOUTPUT query = "GetParks" StartRow = "#StartRow#"
MAXROWS = "#MaxRows#">
<tr>
<td valign = top bgcolor = ffffed>
<b>#GetParks.CurrentRow#</b>
</td>
<td valign = top>
<font SIZE = "-1">#ParkName#</font>
</td>
<td valign = top>
<font SIZE = "-1">#Region#</font>
</td>
<td valign = top>
<font SIZE = "-1">#State#</font>
</td>
</tr>
</CFOUTPUT>
</table>

<!--- Navigation Table --->
<table border=1>

<tr>
<!---go to First Row--->
<td>
<CFIF StartRow NEQ 1>
<a href = "sample.cfm?startrow=1">First Row</a>
</CFIF>
</td>
<!---go to next 10 Rows--->

<td>
<CFIF (StartRow + MaxRows) LTE GetParks.RecordCount>
<a href = "sample.cfm?startrow=<cfoutput>#StartRow + MaxRows#
</cfoutput>">Next <CFOUTPUT>#MaxRows#</CFOUTPUT> rows</a>
</CFIF>
</td>
<!---go to Previous 10 Rows--->

<td>
<CFIF StartRow NEQ 1>
<a href = "sample.cfm?startrow=<cfoutput>#StartRow - MaxRows#
</cfoutput>">Previous <CFOUTPUT>#MaxRows#</CFOUTPUT> rows</a>
</CFIF>
</td>
<!---go to Last Row--->

<td>
<CFIF (StartRow + MaxRows) LTE GetParks.RecordCount>
<a href = "sample.cfm?startrow=<cfoutput>#GetParks.RecordCount - 9#</cfoutput>">Last Row</a>
</CFIF>
</td>
</tr>
</table>
</body>
</html>

 

About This Tutorial
Author: carlos batista
Skill Level: Beginner 
 
 
 
Platforms Tested: CF8
Total Views: 11,186
Submission Date: July 29, 2009
Last Update Date: July 29, 2009
All Tutorials By This Autor: 3
Discuss This Tutorial
Advertisement

Sponsored By...
Powered By...