Hi, I am working on a dynamic results page that uses a form variable in the
recordset. When I test the recordset it comes back with the correct results
but when I check it using the results page I get no records returned. When I
remove the form variable from the recordset the results page displays all of
the records like it should. This one has me stumped. Here is the results page
code with the form variable included. I am sure it is something simple and I
just can't see it. Any help would be appreciated. Thanks, Shane
<cfparam name="FORM.model" default="1">
<cfparam name="PageNum_searchResultsTest" default="1">
<cfquery name="searchResultsTest" datasource="saa">
SELECT make, model, veh_year, ext_color, int_color, primary_image_path,
mileage, price FROM saa.vehicle_ad WHERE model = '#FORM.model#' ORDER BY price
ASC
</cfquery>
<cfset MaxRows_searchResultsTest=10>
<cfset
StartRow_searchResultsTest=Min((PageNum_searchResultsTest-1)*MaxRows_searchResul
tsTest+1,Max(searchResultsTest.RecordCount,1))>
<cfset
EndRow_searchResultsTest=Min(StartRow_searchResultsTest+MaxRows_searchResultsTes
t-1,searchResultsTest.RecordCount)>
<cfset
TotalPages_searchResultsTest=Ceiling(searchResultsTest.RecordCount/MaxRows_searc
hResultsTest)>
<!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>Untitled Document</title>
</head>
<body>
<table border="1">
<tr>
<td>make</td>
<td>model</td>
<td>veh_year</td>
<td>ext_color</td>
<td>int_color</td>
<td>primary_image_path</td>
<td>mileage</td>
<td>price</td>
</tr>
<cfoutput query="searchResultsTest" startRow="#StartRow_searchResultsTest#"
maxRows="#MaxRows_searchResultsTest#">
<tr>
<td>#searchResultsTest.make#</td>
<td>#searchResultsTest.model#</td>
<td>#searchResultsTest.veh_year#</td>
<td>#searchResultsTest.ext_color#</td>
<td>#searchResultsTest.int_color#</td>
<td>#searchResultsTest.primary_image_path#</td>
<td>#searchResultsTest.mileage#</td>
<td>#searchResultsTest.price#</td>
</tr>
</cfoutput>
</table>
</body>
</html>
Dan Bracuk - 28 Oct 2005 02:12 GMT
What was the value of form.model?
Are there actually any records that match it exactly?
Originally posted by: Shane930
Hi, I am working on a dynamic results page that uses a form variable in the
recordset. When I test the recordset it comes back with the correct results
but when I check it using the results page I get no records returned. When I
remove the form variable from the recordset the results page displays all of
the records like it should. This one has me stumped. Here is the results page
code with the form variable included. I am sure it is something simple and I
just can't see it. Any help would be appreciated. Thanks, Shane
<cfparam name="FORM.model" default="1">
<cfparam name="PageNum_searchResultsTest" default="1">
<cfquery name="searchResultsTest" datasource="saa">
SELECT make, model, veh_year, ext_color, int_color, primary_image_path,
mileage, price FROM saa.vehicle_ad WHERE model = '#FORM.model#' ORDER BY price
ASC
</cfquery>
<cfset MaxRows_searchResultsTest=10>
<cfset
StartRow_searchResultsTest=Min((PageNum_searchResultsTest-1)*MaxRows_searchResul
tsTest+1,Max(searchResultsTest.RecordCount,1))>
<cfset
EndRow_searchResultsTest=Min(StartRow_searchResultsTest+MaxRows_searchResultsTes
t-1,searchResultsTest.RecordCount)>
<cfset
TotalPages_searchResultsTest=Ceiling(searchResultsTest.RecordCount/MaxRows_searc
hResultsTest)>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<table border="1">
<tr>
<td>make</td>
<td>model</td>
<td>veh_year</td>
<td>ext_color</td>
<td>int_color</td>
<td>primary_image_path</td>
<td>mileage</td>
<td>price</td>
</tr>
<cfoutput query="searchResultsTest" startRow="#StartRow_searchResultsTest#"
maxRows="#MaxRows_searchResultsTest#">
<tr>
<td>#searchResultsTest.make#</td>
<td>#searchResultsTest.model#</td>
<td>#searchResultsTest.veh_year#</td>
<td>#searchResultsTest.ext_color#</td>
<td>#searchResultsTest.int_color#</td>
<td>#searchResultsTest.primary_image_path#</td>
<td>#searchResultsTest.mileage#</td>
<td>#searchResultsTest.price#</td>
</tr>
</cfoutput>
</table>
</body>
</html>
Shane930 - 28 Oct 2005 20:04 GMT
Hi Dan, the model is "Odyssey" and there are 4 records in the DB that match it exactly. I am not sure if it is a CF output issue or how I have the query set up.
Thanks for you help
Shane
Dan Bracuk - 28 Oct 2005 20:09 GMT
Turn on your de-bugging, and look at the query. See if there are any records
returned. If not, copy and paste it into something that will run against your
database directly, without cold fusion.
Things that could mess you up are,
- leading or trailing spaces
- mixed case compared to upper or lower case.
Originally posted by: Shane930
Hi Dan, the model is "Odyssey" and there are 4 records in the DB that match it
exactly. I am not sure if it is a CF output issue or how I have the query set
up.
Thanks for you help
Shane