Re: Need help with PHP & MySQL

by "Lisa Bradshaw" <zibbler(at)web-design-cs.com>

 Date:  Fri, 3 May 2002 20:24:54 -0400
 To:  <hwg-techniques(at)hwg.org>
 References:  D1C4FN01 ntlworld pieceoshit king
  todo: View Thread, Original
Okay, I'm getting closer. I used your suggestion and it worked great, so I
took it a step further to include the other elements in the form, then it
didn't work :-(   I get a warning that says: Warning: Supplied argument is
not a valid MySQL result resource. Here's the code I used. Maybe you can
spot something I did wrong?


if (isset($alpha)&&!empty($alpha)) $alpha_clause=" AND Alpha='$alpha' ";
else $alpha_clause='';

if (isset($county)&&!empty($county)) $county_clause="County='$county' ";
else $county_clause='';

if (isset($cuisine)&&!empty($cuisine)) $cuisine_clause=" AND
Cuisine='$cuisine' ";
else $cuisine_clause='';

if (isset($price)&&!empty($price)) $price_clause=" AND Price='$price' ";
else $price_clause='';

$result=mysql_query("SELECT * FROM
Restaurants WHERE $county_clause $alpha_clause $cuisine_clause
$price_clause ORDER BY Name");

Thanks again,
Lisa

----- Original Message -----
From: "Darrell King" <darrell(at)webctr.com>
To: <hwg-techniques(at)hwg.org>
Sent: Friday, May 03, 2002 6:50 PM
Subject: Re: Need help with PHP & MySQL


>
> if (isset($alpha)&&!empty($alpha)) $alpha_clause=" AND Alpha='$ alpha' ";
> else $alpha_clause='';
>
> $result=mysql_query("SELECT * FROM
> Restaurants WHERE County='$county' $alpha_clause AND Cuisine='$cuisine'
> AND Price='$price' ORDER BY Name");
>
> ...etc with the other where clause elements.
>
> I didn't test this particular code, obviously, but I have used this
> technique successfully.
> D
>
>

HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA