Here one I wrote in two parts. The first one does all the calculations to give you all
the info you need to display Prev page and Next page buttons in any format you like:
(note: I replaced the <> with [] because my mail program always messes up display of
any HTML-like tags.
<!---
// Module qpager.cfm
// Peter Theobald 8/10/2000
// [EMAIL PROTECTED]
// Calculate numbers for paged query data
//
// Usage:
// set qpager=StructNew()
// set qpager.startrow (def: 1), qpager.maxrows (def: 10), qpager.numrecords (req.)
// <cfinclude template="qpager.cfm">
//
// Outputs: qpager.prevstart, qpager.nextstart,
// qpager.numpages, qpager.thispage, qpager.endrow
--->
[cfscript]
if (NOT IsDefined("qpager.recordcount")) qpager.recordcount=1;
if (NOT IsDefined("qpager.startrow")) qpager.startrow=1;
if (NOT IsDefined("qpager.maxrows")) qpager.maxrows=10;
// Why can't CF be zero based like any sane language?
qpager.numpages = (qpager.recordcount-1)\qpager.maxrows +1;
qpager.thispage = (qpager.startrow-1)\qpager.maxrows +1;
qpager.prevstart = ((qpager.startrow-2)\qpager.maxrows)
* qpager.maxrows +1;
if (qpager.prevstart LT 0) qpager.prevstart = 1;
qpager.endrow = qpager.startrow+qpager.maxrows -1;
if (qpager.endrow GT qpager.recordcount)
qpager.endrow = qpager.recordcount;
qpager.nextstart = qpager.startrow+qpager.maxrows;
if (qpager.nextstart GT qpager.recordcount)
qpager.nextstart = qpager.startrow;
[/cfscript]
Now you can use qpager.startrow, qpager.maxrows, qpager.numrecords, qpager.prevstart,
qpager.nextstart, qpager.numpages, qpager.thispage, qpager.endrow
To do any style you like. For example: (remember to replace all [ with < in my example)
<!---
// dsp_qpager.cfm
// Peter Theobald
// Display query page controls. All links point back to the same page.
// Must be preceeded by fn_qpager.cfm
//
--->
[cfoutput>
[form name="dsp_qpager_form" action="#CGI.SCRIPT_NAME#" method=post>
[input type=hidden name="startrow" value="#qpager.startrow#">
[input type=hidden name="sortby" value="#sortby#">
[div align=right>
View [select name="maxrows" onChange="document.dsp_qpager_form.submit();">
[option value="10" [cfif qpager.maxrows EQ 10>SELECTED</CFIF>>10[/option>
[option value="30" [cfif qpager.maxrows EQ 30>SELECTED</CFIF>>30[/option>
[option value="50" [cfif qpager.maxrows EQ 50>SELECTED</CFIF>>50[/option>
[option value="100" [cfif qpager.maxrows EQ 100>SELECTED</CFIF>>100[/option>
[option value="500" [cfif qpager.maxrows EQ 500>SELECTED</CFIF>>500[/option>
[/select> per page[/div>[/form>
[cfif qpager.numpages GT 1>
[div align=right>Viewing #qpager.startrow# - #qpager.endrow# of #qpager.recordcount#
<a
href="#CGI.SCRIPT_NAME#?startrow=#qpager.prevstart#&maxrows=#qpager.maxrows#&sortby=#sortby#">PREV</a>
[a
href="#CGI.SCRIPT_NAME#?startrow=#qpager.nextstart#&maxrows=#qpager.maxrows#&sortby=#sortby#">NEXT</a>[/div>
[/cfif>
[/cfoutput>
At 11:34 AM 8/24/00 +0100, Neil Middleton wrote:
>All,
>
>Do any of you lot know of any custom tags that will build the [1-10][11-20]
>style navigation at the bottom of a long list of results, the sort of thing
>that appears a LOT on search engines?
>--
>Neil Middleton
>Technical Director
>Stez Media
>
>
>Neil Middleton studied ancient Greek and Roman warfare with the aim of world
>domination.
>He's now a ColdFusion programmer.
>
>------------------------------------------------------------------------------
>Archives: http://www.mail-archive.com/[email protected]/
>To Unsubscribe visit
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
>message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
---------------------------------------------------------------------------
Peter Theobald, Chief Technology Officer
LiquidStreaming http://www.liquidstreaming.com
[EMAIL PROTECTED]
Phone 1.212.545.1232 Fax 1.212.679.8032
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.