Kelly,
> Well if it doesn't matter just don't pass the parameter have it set with a
> value of "" and
> then when you run the query <CFIF parameter IS "YES">where hottub =
> Yes</CFIF>etc
> that way if they pass the parameter blank it won't include it in the
search,
> hence pulling
> up records that do and/or don't include hottubs. Is that what you mean? If
> not let me know.
Yes, that's exactly what I mean, but I'm afraid I'm still not sure what goes
where.
Here's what I currently have on the search page:
<td>
<p>Hot Tub: </p>
<p>
<select name="hashottub">
<option selected>Doesn't Matter</option>
<option value="1">Yes</option>
</select>
</p>
</td>
And here's the results page, below (code generated mostly by UltraDev..),
where I haven't yet referred to the search variable "hashottub" from the
search page. Would you possibly be so kind as to explain where the <cfif>
goes and possibly clarify what my variables should look like?
Thank you so much,
P@tty
<cfinclude template="Connections/connAsheville.cfm">
<cfparam name="distance" default="200">
<cfparam name="numberbedrooms" default="1">
<cfparam name="numberbathrooms" default="1">
<cfparam name="sleepsatleast" default="1">
<cfparam name="rs2__vardistance" default="#distance#">
<cfparam name="rs2__varnumberbedrooms" default="#numberbedrooms#">
<cfparam name="rs2__varnumberbathrooms" default="#numberbathrooms#">
<cfparam name="rs2__varsleepsatleast" default="#sleepsatleast#">
<cfquery name="rs2" datasource=#MM_connAsheville_DSN#
username=#MM_connAsheville_USERNAME# password=#MM_connAsheville_PASSWORD#>
SELECT cabins.cabinID, cabins.cabinName, cabins.cabinCity,
cabins.cabinBedrooms,
cabins.cabinBathrooms, cabins.cabinSleeps, cabins.cabinNightly,
cabins.cabinWeekly,
photos.photosThumbPhotoName FROM cabins INNER JOIN photos ON cabins.cabinID
=
photos.cabinID WHERE cabinDistance <= #rs2__vardistance# AND cabinBedrooms
>=
#rs2__varnumberbedrooms# AND cabinBathrooms >= #rs2__varnumberbathrooms# AND
cabinSleeps
>= #rs2__varsleepsatleast# ORDER BY cabinName
</cfquery>
<cfset rs2_NumRows = 0>
<cfset rs2_Index = 1>
<cfscript>
Repeat1_NumRows = 5;
rs2_NumRows = rs2_NumRows + Repeat1_NumRows;
</cfscript>
<cfscript>
// *** Recordset Stats, Move To Record, and Go To Record: set stats
variables
// set the record count
rs2_total = rs2.RecordCount;
// set the number of rows displayed on this page
If (rs2_NumRows LT 0 OR rs2_NumRows GTE rs2_total) {
rs2_NumRows = rs2_total;
} Else If (rs2_NumRows EQ 0) {
rs2_NumRows = 1;
}
// set the first and last displayed record
rs2_first = Min(1, rs2_total);
rs2_last = Min(rs2_NumRows, rs2_total);
</cfscript>
<cfscript> MM_paramName = "";
</cfscript>
<cfscript>
// *** Move To Record and Go To Record: declare variables
MM_rs = rs2;
MM_rsCount = rs2_total;
MM_size = rs2_NumRows;
MM_uniqueCol = "";
MM_paramName = "";
MM_offset = 1;
MM_atTotal = false;
MM_paramIsDefined = false;
If (MM_paramName NEQ "") MM_paramIsDefined = IsDefined(MM_paramName);
</cfscript>
<cfscript>
// *** Move To Record: handle 'index' or 'offset' parameter
If (NOT MM_paramIsDefined AND MM_rsCount NEQ 0) {
// use index parameter if defined, otherwise use offset parameter
If (IsDefined("index")) {
MM_offset = index;
} Else If (IsDefined("offset")) {
MM_offset = offset;
}
// check if we are past the end of the recordset
If (MM_offset GT MM_rsCount OR MM_offset EQ 0) { // past end or move
last
If ((MM_rsCount MOD MM_size) NEQ 0) { // last page not a full repeat
region
MM_offset = MM_rsCount - (MM_rsCount MOD MM_size) + 1;
} Else {
MM_offset = MM_rsCount - MM_size + 1;
}
}
}
</cfscript>
<cfscript>
// *** Move To Record: replace the current query, for navigation on a detail
page
If (MM_size EQ 1) { // if no repeated regions are defined
// create a new query with one row
MM_newQuery = QueryNew(MM_rs.ColumnList);
QueryAddRow(MM_newQuery, 1);
// copy the data in the row pointed to by MM_offset to the new query
MM_columns = ListToArray(MM_rs.ColumnList,",");
For (i=1; i LTE ArrayLen(MM_columns); i=i+1) {
QuerySetCell(MM_newQuery, MM_columns[i],
MM_rs[MM_columns[i]][MM_offset], 1);
}
// change the recordset to be only this one row
rs2 = MM_newQuery;
}
</cfscript>
<cfscript>
// *** Move To Record: update recordset stats
// set the first and last displayed record
rs2_first = Min(MM_offset, MM_rsCount);
rs2_last = Min(MM_offset + MM_size - 1, MM_rsCount);
// set the starting index for repeated regions on this recordset
rs2_Index = MM_offset;
// set the boolean used by hide region to check if we are on the last record
MM_atTotal = (MM_offset + MM_size - 1 GTE MM_rsCount);
</cfscript>
<cfscript>
// *** Go To Record and Move To Record: create strings for maintaining URL
and Form parameters
// create the list of parameters which should not be maintained
MM_removeList = "&index=";
If (MM_paramName NEQ "") MM_removeList = MM_removeList & "&" & MM_paramName
& "=";
MM_keepURL=""; MM_keepForm=""; MM_keepBoth=""; MM_keepNone="";
// add the existing URL parameters to the MM_keepURL string
MM_params=ListToArray(CGI.QUERY_STRING,"&");
For (i=1; i LTE ArrayLen(MM_params); i=i+1) {
If (FindNoCase("&" & GetToken(MM_params[i],1,"=") & "=",MM_removeList) Is
0)
MM_keepURL = MM_keepURL & "&" & MM_params[i];
}
// add the existing Form variables to the MM_keepForm string
If (IsDefined("FORM.FieldNames")) {
MM_params=ListToArray(FORM.FieldNames,",");
For (i=1; i LTE ArrayLen(MM_params); i=i+1) {
If (FindNoCase("&" & MM_params[i] & "=",MM_removeList) Is 0)
MM_keepForm = MM_keepForm & "&" & LCase(MM_params[i]) & "=" &
URLEncodedFormat(Evaluate("FORM." & MM_params[i]));
}
}
// create the Form + URL string and remove the intial '&' from each of the
strings
MM_keepBoth = MM_keepURL & MM_keepForm;
If (MM_keepURL NEQ "") MM_keepURL = RemoveChars(MM_keepURL,1,1);
If (MM_keepForm NEQ "") MM_keepForm = RemoveChars(MM_keepForm,1,1);
If (MM_keepBoth NEQ "") MM_keepBoth = RemoveChars(MM_keepBoth,1,1);
</cfscript>
<cfscript>
// *** Move To Record: set the strings for the first, last, next, and
previous links
MM_keepMove = MM_keepBoth;
MM_moveParam = "index";
// if the page has a repeated region, remove 'offset' from the maintained
parameters
if (MM_size GT 1) {
MM_moveParam = "offset";
MM_params = ListToArray(MM_keepMove,"&");
MM_keepMove = "";
For (i=1; i LTE ArrayLen(MM_params); i=i+1) {
If (CompareNoCase(GetToken(MM_params[i],1,"="),MM_moveParam) IS NOT 0) {
MM_keepMove = MM_keepMove & "&" & MM_params[i];
}
}
If (MM_keepMove NEQ "") {
MM_keepMove = RemoveChars(MM_keepMove,1,1);
}
}
// set the strings for the move to links
if (MM_keepMove NEQ "") MM_keepMove = MM_keepMove & "&";
urlStr = CGI.SCRIPT_NAME & "?" & MM_keepMove & MM_moveParam & "=";
MM_moveFirst = urlStr & "1";
MM_moveLast = urlStr & "0";
MM_moveNext = urlStr & (MM_offset + MM_size);
MM_movePrev = urlStr & Max(MM_offset-MM_size,1);
</cfscript>
<html>
<head>
<title>Results Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="author" content="Web site designed and produced by Carolina Web
Solutions">
<link rel="stylesheet" href="asheville.css" type="text/css">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Results: Records <cfoutput>#rs2_first#</cfoutput> to
<cfoutput>#rs2_last#</cfoutput> of <cfoutput>#rs2_total#</cfoutput></p>
<p><A HREF="<cfoutput>#MM_movePrev#</cfoutput>">Previous
5</A> · <A HREF="<cfoutput>#MM_moveNext#</cfoutput>">Next
5</A></p>
<table width="100%" border="1" cellspacing="0" cellpadding="5"
align="center">
<tr>
<td><b>Cabin</b></td>
<td><b>Location</b></td>
<td><b>Bedrooms</b></td>
<td><b>Bathrooms</b></td>
<td><b>Sleeps at Least</b></td>
<td><b>Nightly Rate</b></td>
<td><b>Weekly Rate</b></td>
<td><b>Thumbnail Photo</b></td>
</tr>
<cfscript>
Repeat1_StartRow = rs2_Index;
rs2_Index = Min(rs2_Index + Repeat1_NumRows, rs2.RecordCount);
</cfscript>
<cfoutput query="rs2" startrow=#Repeat1_StartRow#
maxrows=#Repeat1_NumRows#>
<tr>
<td>
<div align="center"><A HREF="detail_2.cfm?#Trim(MM_keepURL &
Iif(MM_keepURL NEQ '',DE('&'),DE('')) & 'cabinID=' &
rs2.cabinID)#">#rs2.cabinName#</A></div>
</td>
<td>
<div align="center">#rs2.cabinCity#</div>
</td>
<td>
<div align="center">#rs2.cabinBedrooms#</div>
</td>
<td>
<div align="center">#rs2.cabinBathrooms#</div>
</td>
<td>
<div align="center">#rs2.cabinSleeps#</div>
</td>
<td>
<div align="center">$#rs2.cabinNightly#</div>
</td>
<td>
<div align="center">$#rs2.cabinWeekly#</div>
</td>
<td>
<div align="center"><A HREF="detail_2.cfm?#Trim(MM_keepURL &
Iif(MM_keepURL NEQ '',DE('&'),DE('')) & 'varcabinID=' & rs2.cabinID)#"><img
src="#rs2.photosThumbPhotoName#" border="0"></A></div>
</td>
</tr>
</cfoutput>
</table>
</body>
</html>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists