this one is fun!

duplicate this custom tag I wrote:
(go all the way to the bottom for more info on the query output)

pageArrows.cfm
------------------------------------------------------
<!---
|| BEGIN FUSEDOC ||

|| RESPONSIBILITIES ||
        displays page left and right arrows and page numbers

|| HISTORY ||
Author: Bryan Love ; [EMAIL PROTECTED] ; 10/10/00

|| ATTRIBUTES ||
-> attributes.StartRow                  R       what is the current start
row?
-> attributes.maxRows                   R       how many rows per page
-> attributes.totalRows         R       how many rows did the query return
-> attributes.url                               R       where the anchor
tags point
-> attributes.showPageLinks     O       display list of all pages as links
or just display current page number

|| EXAMPLE ||
        <cfmodule template="../../CustomTags/utilities/TAGPageArrows.cfm"
                                maxRows = "#maxRows#"
                                totalRows = "#qQueryName.recordcount#"
                                startRow="#url.startRow#"
                                showPageLinks="0"
                                url="index.cfm?action=siteList">
                                
|| END FUSEDOC ||
--->

<cfparam name="attributes.showPageLinks" default="1">

<cfset nextStartRow = attributes.startRow + attributes.maxRows>
<cfset prevStartRow = attributes.startRow - attributes.maxRows>
<cfset currPage = int(nextStartRow / attributes.maxRows)>
<cfset totalPages = ceiling(attributes.totalRows / attributes.maxRows)>

<table align="center" width="100%">
        <tr>
                <td width="10%">
                        <cfif prevStartRow GT 0><a
href="<cfoutput>#attributes.url#&startRow=#prevStartRow#</cfoutput>"><img
src="../images/leftArrow.gif" border="0"></a></cfif>
                </td>
                <td align="center"><b><font size="1">page</font></b>
                <cfoutput>
                        <cfif attributes.showPageLinks>
                                <cfloop from="1" to="#totalPages#"
index="i">
                                        <cfset newStartRow = ((i -1) *
attributes.maxRows) + 1>
                                
                                        <font size="1">|
                                        <cfif currPage IS i>
                                                <b>#i#</b>
                                        <cfelse>
                                                <a
href="#attributes.url#&startRow=#newStartRow#"><font size="1">#i#</font></a>
                                        </cfif>
                                        </font>
                                </cfloop>
                        <cfelse>
                                #currPage# (of #totalPages#)
                        </cfif>
                </cfoutput>
                </td>
                <td align="right" width="10%">
                        <cfif nextStartRow LTE attributes.totalRows><a
href="<cfoutput>#attributes.url#&startRow=#nextStartRow#</cfoutput>"><img
src="../images/rightArrow.gif" border="0"></a></cfif>
                </td>
        </tr>
</table>
------------------------------------------------------


OK, now you also need to do the query output right to make this work;
duplicate the following test page and modify it to your liking:

test.cfm
---------------------------------------------

<cfset maxRows = 10><!--- number of rows to display per page --->
<cfparam name="url.startRow" default="1"><!--- default start row to 1 for
first page hit --->

<cfmodule template="../../CustomTags/utilities/TAGPageArrows.cfm"
                                maxRows = "#maxRows#"
                                totalRows = "#qQueryName.recordcount#"
                                startRow="#url.startRow#"
                                showPageLinks="0"
                                url="index.cfm?action=siteList">

<cfoutput query="qQueryName" startRow="#url.startRow#" maxRows="#maxrows#">
        whatever
</cfoutput>

---------------------------------------------
           
p.s. I whipped up the example page pretty quick, so you'll need to modify it
some to make it do what you want it to.
                                         
Bryan Love ACP
Internet Application Developer
[EMAIL PROTECTED]
                                                    


-----Original Message-----
From: W Luke [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 08, 2001 10:43 AM
To: CF-Talk
Subject: Determining no. of pages in results


Hi,

I have a query which searches a table, and displays results, 10 at a time.
How can I display the page-numbers though, so users can scroll through to a
page further along the query (1,2,3,4 etc)?

To get the number of pages, all I've done is:

<cfset noPages = round(getads.recordcount / 10>

Any ideas?

Thanks.

Will
--
[EMAIL PROTECTED] -=- www.lukrative.com
Local-Advertising -=- www.localbounty.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to