With my PrevNext fuction it is possible to do search results paging real easily. It is used everywhere within this site and in all of my clients' sites. The only requirement is: the name of the query supposed to be splitted should be "Results". Of course it was possible to setup it also as argument but this is unnecessary and not good for code readability. It accepts several arguments allowing to display paging flexible. To use PrevNext you will need second minor function though named PrevNextInc though, but that's all. So sample piece of code using PrevNext function would look like this: <CFSILENT> <CFLOCK scope="SESSION" type="READONLY" timeout="10"> <CFIF not isdefined("SESSION.results.recordcount")> <CFSET needsrequery=1> </CFIF> </CFLOCK> <CFIF isdefined("needsrequery")> <CFQUERY name="results" datasource="#REQUEST.ds#"> select * from schedule order by schedule </CFQUERY> <CFLOCK scope="SESSION" type="EXCLUSIVE" timeout="20"> <CFSET SESSION.results=results> </CFLOCK> </CFIF> <CFSCRIPT> obj=createObject("component","#REQUEST.cfcpath#Globals"); sr=obj.prevNextInc(); </CFSCRIPT> </CFSILENT> <CFINCLUDE template="header.cfm"> <CFSCRIPT>obj.prevnext(0,sr);</CFSCRIPT> <TABLE border="0"> <CFOUTPUT query="Results" startrow="#sr#" maxrows="#REQUEST.maxrows#"> <TR <cfif results.currentrow Mod 2>class="trshade"</cfif>> <TD class="results">#dateformat(datescheduled,"mm/dd/yyyy")#</TD> <TD class="results">#phase#</A></TD> <TD class="results">#dateformat(datecompleted,"mm/dd/yyyy")#</TD> </TR> </CFOUTPUT> </TABLE> <CFSCRIPT>obj.prevnext(0,sr);</CFSCRIPT> <CFINCLUDE template="footer.cfm"> (replace REQUEST.cfcpath, queried table ("Schedule"), header.cfm and footer.cfm with your values in the code above) |