Just a couple of notes:
1. Why not use a cached query so it doesn't reexecute on each page
2. Be careful using a url parameter (url.id) in a query without first
validating it. You are leaving yourself open to hackers
(http://www.vawter.com/urlhack.cfm)
----- Original Message -----
From: "Michael Wilson" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Monday, August 20, 2001 7:59 AM
Subject: RE: Next and previous records
> Thanks
>
> This is what I wound up going with. Seems to be working fine so far.
>
> ...thanks, Joseph.
>
>
> <CFQUERY NAME="GetRecords" DATASOURCE="xionmediacom">
> SELECT portfolio.*, media.*, clients.Client, portfolio.Description AS
> PortDesc
> FROM portfolio, media, clients
> WHERE portfolio.TypeID = #URL.ID#
> And portfolio.ID = media.PortfolioID
> AND portfolio.ClientID = clients.ID
> AND portfolio.ActiveStatus = 1
> AND media.ActiveStatus = 1
> ORDER BY clients.Client
> </CFQUERY>
>
> !---Assign default value for "start"--->
> <cfparam name="start" default="1">
>
> !---Assign default value for "display"--->
> <cfset display = 1>
>
> <!---Calculate the "next" value--->
> <cfset nextX = #start# + #display#>
>
> <!---Calculate the "previous" value--->
> <cfset PrevX = #start# - #display#>
> <cfif PrevX LTE 0>
> <cfset PrevX = 1>
> </cfif>
>
>
> <html>
> <head>
> <cfoutput><title>#title#</title></cfoutput>
> </head>
>
> <body>
>
> <!---Output results--->
>
> <h2>Results Page</h2>
>
> <cfoutput query="GetRecords" startrow="#start#" maxrows="#display#">
> #PortDesc#<br>
> </cfoutput>
>
> <!---Previous (X) (only show this link if there are "previous"
results)--->
>
> <cfif #start# is not 1>
> <cfoutput>
> <a href="thispage.cfm?start=#PrevX#&display=#display#&ID=#URL.ID#">
> previous
> </a>
> </cfoutput>
> </cfif>
>
>
>
> <!---Next (X) (only show this link if there are more results
available)--->
>
> <cfif nextX LTE GetRecords.RecordCount>
> <cfoutput>
> <a href="thispage.cfm?start=#nextX#&display=#display#&ID=#URL.ID#">
> next
> </a>
> </cfoutput>
> </cfif>
>
>
> </body>
> </html>
>
> >-----Original Message-----
> This one also takes "keyword" as a paramater... It may be closer to what
you
> need. (even supports multiple columns)
>
> http://cfhub.com/discussion/viewmessages.cfm?Forum=11&Topic=422
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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