$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: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
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
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to