I currently use the following code in a few different places in my
application. It works fast and good....I am posting it because many people
helped me getting started using CF and I hope to continue the
tradition........If you come up with something better that is awesome, just
post it for others to use.......Stango
<!--- This code assumes that you are displaying the records in
groups of five--->
<cfquery name="the_query_you_are_using"
datasource="your_datasource">
Query meat goes here
</cfquery>
<cfif isDefined('get_previous')>
<cfset number = get_previous - 8>
<cfset end = get_previous - 4>
<cfif number lte 0>
<cfset number = 1>
</cfif>
<cfelse>
<cfif number is 1>
<cfset end = number + 4>
<cfelse>
<cfset end = number + 4>
</cfif>
</cfif>
<cfloop query="the_query_you_are_using" startrow="#number#"
endrow="#end#">
Display meat goes here
</cfloop>
<cfif the_query_you_are_using.recordcount gte 5>
<cfif end gt 5>
<input type="button" Value="Previous"
onClick="document.location='ProgressNotes_Sel.cfm?get_previous=
<cfoutput>#Evaluate(end-1)#</cfoutput>&plusotherformvariables'">
</cfif>
</cfif>
<cfif end lt the_query_you_are_using.recordcount>
<input type="button" Value="Next"
onClick="document.location='ProgressNotes_Sel.cfm?number=<cfoutput>#Evaluate
(end+1)#</cfoutput>&plusotherformvariables'">
</cfif>
<!--- YOU CAN USE THIS LAST PART TO SHOW THE USER EXACTLY WHAT
RECORD THEY ARE CURRENTLY LOOKING ON--->
<cfif end gt get_services.recordcount>
<cfset last = get_services.recordcount>
<cfelse>
<cfset last = end>
</cfif>
<cfoutput>#get_services.recordcount# record<cfif
get_services.recordcount neq 1>s</cfif> returned....showing record<cfif
number neq get_services.recordcount>s #number# through</cfif>
#last#</cfoutput>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists