Welcome to Dream.In.Code
Getting Help is Easy!

Join 117,542 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,659 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



COLDFUSION

 
Reply to this topicStart new topic

COLDFUSION, NEXT PAGE RESULTS

perezn470
post 24 Apr, 2008 - 07:24 PM
Post #1


New D.I.C Head

*
Joined: 24 Apr, 2008
Posts: 1

I am very, very new to ColdFusion and am trying to make my job alot easier. I have made gotten as far as making a search page which gives you the option to search by either ID number or First Name or Last Name. Upon submitting I get the 10 results on the first page. the problem is when i click on the "NEXT" button it gives me an error message which is displayed in the attachment. Thank you in advance for any and all assistance you give me with this issue.
CODE

<cfparam name="PageNum_Prisoner" default="1">
<cfset WhereClause = " 0=0">
<!--- Search by First Name --->
<cfif FORM.FirstName IS NOT "">
  <cfset WhereClause = WhereClause & " AND FirstName LIKE '%" &  FORM.FirstName & "%'">
</cfif>
<!--- Search by Last Name --->
<cfif FORM.LastName IS NOT "">
  <cfset WhereClause = WhereClause & " AND LastName LIKE '%" &  FORM.LastName & "%'">
</cfif>
<!--- Search by CB Number which is the ArrestID --->
<cfif FORM.ArrestID IS NOT "">
  <cfset WhereClause = WhereClause & " AND ArrestID LIKE '%" &  FORM.ArrestID & "%'">
</cfif>
<!--- Query --->
<cfquery name="Prisoner" datasource="Prisoner">
SELECT ArrestID, FirstName, MiddleName, LastName
FROM tblprisoner
</cfquery>
<cfset MaxRows_Prisoner=10>
<cfset StartRow_Prisoner=Min((PageNum_Prisoner-1)*MaxRows_Prisoner+1,Max(Prisoner.RecordCount,1))>
<cfset EndRow_Prisoner=Min(StartRow_Prisoner+MaxRows_Prisoner-1,Prisoner.RecordCount)>
<cfset TotalPages_Prisoner=Ceiling(Prisoner.RecordCount/MaxRows_Prisoner)>
<cfset QueryString_Prisoner=Iif(CGI.QUERY_STRING NEQ "",DE("&"&XMLFormat(CGI.QUERY_STRING)),DE(""))>
<cfset tempPos=ListContainsNoCase(QueryString_Prisoner,"PageNum_Prisoner=","&")>
<cfif tempPos NEQ 0>
  <cfset QueryString_Prisoner=ListDeleteAt(QueryString_Prisoner,tempPos,"&")>
</cfif>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Prisoner Results</title>
</head>

<body>
<table align="center" width="200" border="1" bordercolor="#0000FF">
  <tr>
    <th scope="col">CB#</th>
    <th scope="col">First Name </th>
    <th scope="col">Last Name </th>
  </tr>
  <cfoutput query="Prisoner" startRow="#StartRow_Prisoner#" maxRows="#MaxRows_Prisoner#">
    <tr>
      <td>#Prisoner.ArrestID#</td>
      <td>#Prisoner.FirstName#</td>
      <td>#Prisoner.LastName#</td>
    </tr>
  </cfoutput>
</table>
<br>
<table border="0" width="50%" align="center">
  <cfoutput>
    <tr>
      <td width="23%" align="center"><cfif PageNum_Prisoner GT 1>
        <a href="#CurrentPage#?PageNum_Prisoner=1#QueryString_Prisoner#">First</a>
      </cfif>
      </td>
      <td width="31%" align="center"><cfif PageNum_Prisoner GT 1>
        <a href="#CurrentPage#?PageNum_Prisoner=#Max(DecrementValue(PageNum_Prisoner),1)##QueryString_Prisoner#">Previous</a>
      </cfif>
      </td>
      <td width="23%" align="center"><cfif PageNum_Prisoner LT TotalPages_Prisoner>
        <a href="#CurrentPage#?PageNum_Prisoner=#Min(IncrementValue(PageNum_Prisoner),TotalPages_Prisoner)##QueryString_Prisoner#">Next</a>
      </cfif>
      </td>
      <td width="23%" align="center"><cfif PageNum_Prisoner LT TotalPages_Prisoner>
        <a href="#CurrentPage#?PageNum_Prisoner=#TotalPages_Prisoner##QueryString_Prisoner#">Last</a>
      </cfif>
      </td>
    </tr>
  </cfoutput>
</table>
<br>

</body>
</html>



Attached thumbnail(s)
Attached Image
User is offlineProfile CardPM

Go to the top of the page


skyhawk133
post 24 Apr, 2008 - 08:31 PM
Post #2


Head DIC Head

Group Icon
Joined: 17 Mar, 2001
Posts: 14,600



Thanked 39 times

Dream Kudos: 1650

Expert In: Web Development

My Contributions


You need to continue to pass firstname and/or id to the "next" page. You're passing it the firstname from the form, but when you click next, firstname is not stored anywhere. You should add it as another variable in the URL for the "next" link.


Also, and this won't fix your problem, but it will fix your error... you can put <cfif isdefined('firstname') AND firstname NEQ "">

That will check if the variable is even defined before checking to see if it's empty. If it's not defined, it won't error... but it also won't evaluate it since it doesn't exist.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/7/08 05:30PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month