I am building a simple search feature, searching by last name. The results
will be very large and I am trying to dispay 10 results at a time. Everything
works fine until I try to go the the second page. For example, my original
search result is 100 records, out of a total of 5000. The result displays
Records 1 to 10 of 100. I click on the pointer to go to page 2 and the display
changes to 11 out of 5000 and starts from the beginning of the alphabet. What
am I overlooking?
Thanks in advance...
<cfset CurrentPage=GetFileFromPath(GetTemplatePath())>
<cfparam name="form.LName" default="">
<cfparam name="PageNum_qryGetLawyer" default="1">
<cfquery name="qryGetLawyer" datasource="Lawyer1">
SELECT UserID, FNAME, LNAME, Firm, CITY, STATE, ZIP
FROM dbo.tblLawyers
WHERE LNAME LIKE '#Form.LName#%'
ORDER BY LNAME ASC
</cfquery>
<cfset MaxRows_qryGetLawyer=10>
<cfset
StartRow_qryGetLawyer=Min((PageNum_qryGetLawyer-1)*MaxRows_qryGetLawyer+1,Max(qryGetLawyer.RecordCount,1))>
<cfset
EndRow_qryGetLawyer=Min(StartRow_qryGetLawyer+MaxRows_qryGetLawyer-1,qryGetLawyer.RecordCount)>
<cfset
TotalPages_qryGetLawyer=Ceiling(qryGetLawyer.RecordCount/MaxRows_qryGetLawyer)>
<cfset QueryString_qryGetLawyer=Iif(CGI.QUERY_STRING NEQ
"",DE("&"&XMLFormat(CGI.QUERY_STRING)),DE(""))>
<cfset
tempPos=ListContainsNoCase(QueryString_qryGetLawyer,"PageNum_qryGetLawyer=","&")>
<cfif tempPos NEQ 0>
<cfset
QueryString_qryGetLawyer=ListDeleteAt(QueryString_qryGetLawyer,tempPos,"&")>
</cfif>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<table border="1" cellpadding="3">
<tr>
<td>UserID</td>
<td>FNAME</td>
<td>LNAME</td>
<td>Firm</td>
<td>CITY</td>
<td>STATE</td>
<td>ZIP</td>
</tr>
<cfoutput query="qryGetLawyer" startrow="#StartRow_qryGetLawyer#"
maxrows="#MaxRows_qryGetLawyer#">
<tr>
<td>#qryGetLawyer.UserID#</td>
<td>#qryGetLawyer.FNAME#</td>
<td>#qryGetLawyer.LNAME#</td>
<td>#qryGetLawyer.Firm#</td>
<td>#qryGetLawyer.CITY#</td>
<td>#qryGetLawyer.STATE#</td>
<td>#qryGetLawyer.ZIP#</td>
</tr>
</cfoutput>
</table>
<table border="0" width="50%" align="center">
<cfoutput>
<tr>
<td width="23%" align="center"><cfif PageNum_qryGetLawyer GT 1>
<a
href="#CurrentPage#?PageNum_qryGetLawyer=1#QueryString_qryGetLawyer#"><img
src="First.gif" border=0></a>
</cfif>
</td>
<td width="31%" align="center"><cfif PageNum_qryGetLawyer GT 1>
<a
href="#CurrentPage#?PageNum_qryGetLawyer=#Max(DecrementValue(PageNum_qryGetLawyer),1)##QueryString_qryGetLawyer#"><img
src="Previous.gif" border=0></a>
</cfif>
</td>
<td width="23%" align="center"><cfif PageNum_qryGetLawyer LT
TotalPages_qryGetLawyer>
<a
href="#CurrentPage#?PageNum_qryGetLawyer=#Min(IncrementValue(PageNum_qryGetLawyer),TotalPages_qryGetLawyer)##QueryString_qryGetLawyer#"><img
src="Next.gif" border=0></a>
</cfif>
</td>
<td width="23%" align="center"><cfif PageNum_qryGetLawyer LT
TotalPages_qryGetLawyer>
<a
href="#CurrentPage#?PageNum_qryGetLawyer=#TotalPages_qryGetLawyer##QueryString_qryGetLawyer#"><img
src="Last.gif" border=0></a>
</cfif>
</td>
</tr>
</cfoutput>
</table>
<cfoutput>Records #StartRow_qryGetLawyer# to #EndRow_qryGetLawyer# of
#qryGetLawyer.RecordCount# </cfoutput>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:184198
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54