Thanks! I think I need to use Int instead of Round. If I have 73 results,
I only want to display links to 1 2 3 4 5 6 7, not to 1 2 3 4 5 6 7 8
In addition, to get the Google format, I need to include
Previous/Next. Finally, I need to display the current page with no link.
The following is my try at matching the Google format (not tested). (Why
follow Google? Very good usability research.)
best, paul
=========================================
<cfset perpage = 10>
<cfset pagesum = Int(yourqName.recordcount/perpage)>
<cfset startrow = 1>
<cfset currentpage = 1>
<cfif pagesum GT 1>
<cfif currentpage GT 1>
<cfset prevstart = startrow - perpage>
<cfoutput><a
href="result.cfm?startrow=#prevstart#&results_per_page=#perpage#">Previous<
/a> </cfoutput>
</cfif>
<cfloop index="link_num" from="1" to="#pagesum#" step="1">
<cfoutput>
<cfif link_num IS currentpage>
#link_num#
<cfelse>
<a
href="result.cfm?startrow=#startrow#&results_per_page=#perpage#">#link_num#<
/a> </cfif>
</cfoutput>
<cfset startrow = startrow + perpage>
<cfset currentpage =
currentpage + 1>
</cfloop>
<cfset nextstart = startrow + perpage>
<cfif nextstart LT yourqName.RecordCount>
<cfoutput><a
href="result.cfm?startrow=#nextstart#&results_per_page=#perpage#">Next</a> </cfoutput>
</cfif>
</cfif>
===========================
At 09:16 AM 12/12/02 -0600, you wrote:
>Here's the basics given a recordcount. A difference from WG's response is
>the use of Ceiling() instead of Round(). Why? Because if you get 73 results
>with a perpage setting of 10 (73/10=7.3). With Round, it will round to the
>nearest integer giving you 7 pages. So you will have only 70 of your 73
>results displayed. This way, it gives you 8 pages with only 3 results
>displayed on the last page.
>
>Have fun!
>
><cfset perpage = 10>
><cfset pagesum = Ceiling(yourqName.recordcount/perpage)>
>
><cfset startrow = 1>
> <cfif pagesum GT 1>
> <cfloop index="link_num" from="1" to="#pagesum#" step="1">
><cfoutput><a
>href="result.cfm?startrow=#startrow#&results_per_page=#perpage#">#link_num#<
>/a> </cfoutput>
> <cfset startrow = startrow + perpage>
> </cfloop>
> </cfif>
>
>-----Original Message-----
>From: paul smith [mailto:[EMAIL PROTECTED]]
>Sent: Thursday, December 12, 2002 7:32 AM
>To: CF-Talk
>Subject: Prev 1 2 3 ... Next
>
>
>Google results offer links like the subject.
>
>Given RecordCount from a query, is there a tag to create links like the
>subject?
>
>Or a script?
>
>best, paul
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm