Try something like this (this template is called "users_list.cfm"):
NOTE: pass the #URL# to this template and the use <cfif
isdefined("URL.Category")>code here</cfelse> error trapping</cfif>
<cfset maxrows="1">
<cfquery name="UserList" datasource="#DataSourceName#"
dbtype="#DatabaseType#" dbname="#DatabaseName#"
dbserver="#DatabaseServer#" username="#DatabaseUserName#"
password="#DatabasePassword#">
SELECT DISTINCT UserID, UserName, UserFirstName, UserMiddleName,
UserLastName, UserEmailAddress, UserLevel
FROM Users
ORDER BY UserLastName ASC
</cfquery>
<cfparam name="start" default="1">
<cfparam name="maxrows" default="#maxrows#">
<cfif UserList.recordcount>
<cfif maxrows GT UserList.recordcount>
<cfset maxrows = UserList.recordcount>
</cfif>
</cfif>
<table width="100%">
<cfoutput>
<cfif UserList.RecordCount GTE 1>
<tr><td align="center" colspan="7">
<cfif UserList.RecordCount GT 1>
<cfset NumUsers = "Users">
<cfelse>
<cfset NumUsers = "User">
</cfif>
<p>#NumUsers# <strong>#start#</strong> through <strong>#iif(val(start +
maxrows - 1) GT
UserList.recordcount,DE(UserList.recordcount),DE(val(start + maxrows -
1)))#</strong> of <strong>#UserList.recordcount#</strong></p><br>
</td></tr>
</cfif>
</cfoutput>
<cfif UserList.RecordCount GTE 1>
<table width="100%">
<tr><th halign="left" width="25%"><font size="2">Surname, First
Middle</font></th><th halign="left" width="25%"><font size="2">User
Name</font></th><th halign="left" width="25%"><font size="2">Email
Address</font></th><th halign="left" width="25%"><font size="2">Access
Level</font></th></tr>
<ul>
<cfoutput query="UserList" startrow="#start#" maxrows="#maxrows#">
<cfif CurrentRow Mod 2>
<tr>
<cfelse>
<tr bgcolor="e9e9e9">
</cfif>
<td valign="top"><p><li type="square"><a
href="users_edit.cfm?#URLToken#&UserID=#UserID#"
onmouseover="self.status='#JSStringFormat("View User
Details...")#';return true" onmouseout="self.status='';return
true">#UserLastName#, #UserFirstName# #UserMiddleName#</a></td><td
valign="top">#UserName#</td><td valign="top"><a
href="mailto:#UserEmailAddress#" onmouseover="self.status='Send user an
email message.';return true" onmouseout="self.status='';return
true">#UserEmailAddress#</a></td><td valign="top">#UserLevel#</td></tr>
</cfoutput>
</ul>
<tr>
<td align="center" colspan="5">
<br><br>
<cfoutput>
<cfif evaluate(start - maxrows) GT val(0)>
<a href="users_list.cfm?start=#val(start - maxrows)#"><img
src="images/prev.gif" width="57" height="24" hspace="5" alt="Previous"
border="0" onmouseover="self.status='Previous';return true"
onmouseout="self.status='';return true"></a>
<cfelseif evaluate(start - maxrows) LT val(1) AND evaluate(start -
maxrows) GT val(1 - maxrows)>
<a href="users_list.cfm?start=1"><img src="images/prev.gif" width="57"
height="24" hspace="5" alt="Previous" border="0"
onmouseover="self.status='Previous';return true"
onmouseout="self.status='';return true"></a>
</cfif>
<cfif start LT val(UserList.recordcount - maxrows + 1)>
<a href="users_list.cfm?start=#val(start + maxrows)#"><img
src="images/next.gif" width="56" height="25" hspace="5" alt="Next"
border="0" onmouseover="self.status='Next';return true"
onmouseout="self.status='';return true"></a>
</cfif>
</cfoutput>
</td></tr>
</table>
Peter Tilbrook
ColdFusion Applications Developer
Australia New Zealand Food Authority
Boeing House
55 Blackall Street
BARTON ACT 2600
Ph: +61-2-6271 2256
Fax: +61-2-6271 2278
http://www.anzfa.gov.au
-----Original Message-----
From: Michael Wilson [mailto:[EMAIL PROTECTED]]
Sent: Monday, 20 August 2001 15:24
To: CF-Talk
Subject: Next and previous records
Hi,
I am working on a project that requires "next example" and "previous
example" navigation for a portfolio section. On the initial portfolio
page
the user is presented with a list of "project types" to choose from...
development, logo design, photography and etc.
Once the user makes a choice, I pop up a new window and proceed to
output
the data for the first record. Right now I have MAXROWS set to 1 so I
can
get the display's look down, otherwise I get every record. Eventually I
would like to allow them to move through the various examples (records)
in
that category type in sequence using the same window and page.
I have looked at some of the next and previous record tutorials, but
most of
them deal with presenting X number of records in groups... like next 5,
last
5.
Given that my query looks for a URL.ID to determine what category to get
the
records from; is there a way to give the user next and last options
using
the same window and page.cfm?
the query in my pop-up cfm is:
<CFQUERY NAME="GetPortfolioContent" DATASOURCE="xionmediacom">
SELECT portfolio.*, media.*, clients.*, 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>
You can see what I am working on, since I probably did a crap job of
explaining myself, at:
http://ax.servehttp.com/clients/xion/portfolio.cfm
Any help is greatly appreciated,
Mike
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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