I wrote a tag that does it, it's called QueryBrowse you can get it at
http://www.cfdev.com/products/index.cfm?ref=126

pete

-----Original Message-----
From: Diana Nichols [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 08, 2001 2:07 PM
To: CF-Talk
Subject: RE: PREVIOUS 1 2 3 ... NEXT page codes


Don't think I've seen a repsonse to this...anyway, here's a piece of code i
wrote to do that very same thing. It shows 25 records per page, and the
pages at the top (previous 1 2 3 4 next) shows 10 pages, which roll with the
current page.


<!---set the params for results--->
<cfparam name="startRow" default="1">
<cfset maxRows = 25>
<cfset prevStartRow = startRow - maxRows>
<cfset nextStartRow = startRow + maxRows>
<cfset thisstartrow=startrow>
<cfparam name=lastrecord default="#evaluate((startrow+maxrows)-1)#">

<!--- display links to pages in search results--->
<cfif prevStartRow GT 0>
        <a
href="index.cfm?smp=projects&startRow=#prevStartRow#&list=#list##string1#">p
revious |</a>
</cfif>
<cfif get.recordcount gt #maxrows#>
        <cfset totalpages=ceiling(get.recordcount /25)>
        <cfset thispage=evaluate(int(thisstartrow/maxrows)+1)>
        <cfif thispage lte 10>
                <cfset firstpage=1>
                <cfif totalpages lt 10><cfset lastpage=totalpages>
                <cfelse><cfset lastpage=10>
                </cfif>
        <cfelseif thispage gte #evaluate(totalpages-5)#>
                <cfset firstpage=#evaluate(totalpages-9)#><cfset lastpage=#totalpages#>
        <cfelse>
                <cfset firstpage=#evaluate(thispage-5)#><cfset
lastpage=#evaluate(thispage+5)#>
        </cfif>

        <cfloop from=#firstpage# to=#lastpage# index=pageno>
                <cfif pageno is not thispage>
                <a
href="index.cfm?smp=projects&startRow=#evaluate((pageno*maxrows)+1-maxrows)#
&list=#list##string1#">
                </cfif>#pageno#<cfif pageno is not thispage></a></cfif> |
        </cfloop>
</cfif>
<cfif nextStartRow LTE get.recordcount>
        <a
href="index.cfm?smp=projects&startRow=#nextStartRow#&list=#list##string1#">n
ext</a>
</cfif>
        &nbsp;&nbsp;&nbsp;#get.recordcount# records found</span>
<cfif get.recordcount lt evaluate(startrow+maxrows)>
        <cfset lastrecord=get.recordcount>
</cfif>
<span class=main>(#startrow# - #lastrecord# shown)</span>
<!---end of pages--->

HTH
D

Diana Nichols
Webmistress
http://www.salesthreads.com
Selling...Simplified



-----Original Message-----
From: nyon [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 07, 2001 9:04 AM
To: CF-Talk
Subject: Re: PREVIOUS 1 2 3 ... NEXT page codes



   Hi,

I manage to created buttons for Previous/Next in a search that returns 10
records each time.
However, how can I put a more direct way  to access the pages  ie. Pages 1 2
3 4 (similiar to search engines).
I know it involves some count, looping procedures.

thanks
nyon
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to