ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old November 13th, 2004, 09:48 AM
Global777 Global777 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 6 Global777 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Recordset Navigation Question

I am building a simple search feature, searching by last name. The results will be very large and I am trying to display 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_qryGetL awyer#"><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>

Reply With Quote
  #2  
Old November 14th, 2004, 09:08 AM
kiteless kiteless is offline
Moderator
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,488 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 18 h 10 m 11 sec
Reputation Power: 42
Too much code there for me to look through quickly. But I'd try narrowing the records returned in the actual SQL statement than rerunning the entire SQL statement on every page request. Just pass the last ID viewed on the previous page and use it in your where clause. You can limit the number returned using the TOP SQL command or with the MAXROWS attribute of CFQUERY.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Recordset Navigation Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway