Re: Advanced Search
| From: | Andrew Brampton | Date: | Wed, 15 Jan 2003 04:35:31 +0000 |
| Subject: | Re: Advanced Search | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-131650@lists.php.net to get a copy of this message | ||
$sql = 'SELECT p.* FROM properties p WHERE ';
if(isSet($city))
$sql .= 'city = "' . $city . '" AND ';
if(isSet($sub_name ))
$sql .= 'sub_name = "' . $sub_name . '" AND ';
....
//Remove last AND and append 'ORDER by price asc'
mysql_query($sql );
Hope this helps
Andrew
----- Original Message -----
From: <rw@xend.net>
To: <php-general@lists.php.net>
Sent: Wednesday, January 15, 2003 4:16 AM
Subject: [PHP] Advanced Search
>
> Hello!
>
> Any quick solutions to this:
>
> if (!$city && !$sub_name && !$address && !$pool && !$waterfront
> &&
!$waterview
> && !$golf && !$type && !$beds)
> {$result = mysql_query("SELECT p.* FROM properties p ORDER by price
asc;");}
> elseif (!$city && !$sub_name && !$address && !$pool &&
> !$waterfront &&
> !$waterview && !$golf && !$type)
> {$result = mysql_query("SELECT p.* FROM properties p WHERE beds >= $beds
ORDER
> by price asc;");}
>
> I don't want to have to write 50 different ifelse statements unless I have
to.
>
> Please show me the way to make the search more efficient.
>
> TIA
>
> RW
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>