I am trying to get the Resultset page listing to work for my page. It works great for all pages 10 and under but when I get over 10 pages it doesnt work correctly:
For example if I have 11 page results and I go to page 2 it will show page 11 as the current page:
1 2 3 4 5 6 7 8 9 10 11
If I have resultset under 10 pages it works great. For example on page 2 it will look like this:
1 2 3 4 5
or if I am on page 4 it will look like this:
1 2 3 4 5
Please advise because I have tried many ways to get a resultset similiar to what is set up on this tek-tips and other sites such as google.
Here is my attempt that is very close but not working correctly with anything over 10 pages:
For example if I have 11 page results and I go to page 2 it will show page 11 as the current page:
1 2 3 4 5 6 7 8 9 10 11
If I have resultset under 10 pages it works great. For example on page 2 it will look like this:
1 2 3 4 5
or if I am on page 4 it will look like this:
1 2 3 4 5
Please advise because I have tried many ways to get a resultset similiar to what is set up on this tek-tips and other sites such as google.
Here is my attempt that is very close but not working correctly with anything over 10 pages:
Code:
<cfparam name="myStart" default="1">
<cfparam name="myDisplay" default="10">
<cfquery name="myQuery" datasource="myQuery" dbtype="ODBC">
select * from myQuery
</cfquery>
<cfoutput query="myQuery" startrow="#myStart#" maxrows="#myDisplay#">
<table width="60%" align="center">
<TR>
<td>
<a href="[URL unfurl="true"]http://mydiretory/myQuery/myPage.cfm?id=#myQuery.id#">#subject#</a></td>[/URL]
</tr>
</table>
</cfoutput>
<cfset NumPages=Ceiling(myQuery.RecordCount / myDisplay)>
<cfloop from="1" to="#NumPages#" index="ThisPage">
<cfoutput>
<cfif ThisPage IS myStart>
<td>#ThisPage#</td>
<cfelse>
<cfset PageNumStart=(((ThisPage - 1) * myDisplay) + 1)>
<td><a href="thePage.cfm?id=#myQuery.id#&StartRow=#PageNumStart#&myStart=#PageNumStart#">#ThisPage#</a></td>
</cfif>
</cfoutput>
</cfloop>