Patty move your ORDER BY past the CFIF and it should work.

Thank You,
Peter

Peter J. MacDonald II
Creative Computing, Inc.
100 Middle Street
Lincoln, RI 02865
Phone: 401.727.0183 x123
Fax: 401.727.4998
Portable: 401.965.3661
E-MAIL: [EMAIL PROTECTED]
Web Page: www.creatcomp.com



-----Original Message-----
From: P@tty Ayers [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 05, 2001 9:21 AM
To: CF-Talk
Subject: Newbie problem: Search on Yes/No Column


Friends:

I thought that I had this solved, but not quite. Can anyone help?

The problem: I need to search on a "yes/no" column - several of them -
allowing the user to choose that this field "Doesn't Matter" or else "Yes".
There's a search page and a results page. The database has a column
"cabinHottub", and the search form a menu "hashottub".

I was given the following (below), which returns all records for the
"Doesn't Matter" menu choice - but for some reason, *also returns all
records for the "Yes" choice*. I'm sure this is something I've done
incorrectly, but I'm afraid I don't know what. This code (see below) is
exactly what I am currently testing.

I feel like there should be something like
<cfparam name="rs2__hashottub" default="#hashottub#">
<cfparam name="hashottub" default="0">

on the Results page as well, but I'm really not sure, obviously. Any help
would be GREATLY appreciated, as I am really stuck on this, and just cannot
find it in the reference books.

Thank you again,

P@tty Ayers
Macromedia Evangelist

-------------------------------------------------------------------------

<!--- Menu search object from Search Page --->

> Put a value of nothing in the option field for doesn't matter. see below:

>         <p>Hot Tub: </p>
>         <p>
>           <select name="hashottub">
>             <option VALUE="" selected>Doesn't Matter</option>
>             <option value="1">Yes</option>
>           </select>
>         </p>

----------------------------------------------------------------------------
<!--- Query from Results Page: --->

> <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
> <CFIF IsDefined("hashottub") and hashottub IS NOT "">
> AND  hashottub = 1
> </CFIF>
> </cfquery>
----------------------------------------------------------------------------
-----
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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

Reply via email to