search by multiple varaibles...
| From: | John Corry | Date: | Thu, 31 Aug 2000 04:17:13 +0000 |
| Subject: | search by multiple varaibles... | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-14518@lists.php.net to get a copy of this message | ||
So far, I have a form that can be used to search a database by three
separate fields.
//relevant generation of query
//base query
$searchStmt = "SELECT *, hi_price, lo_price from $table where " ;
//plus concatenated query
if ($price_key)
$searchStmt .= "price_key like '$price_key' and " ;
if ($title)
$searchStmt .= "title like '$title' and " ;
if ($area)
$searchStmt .= "area like '$area' and " ;
//minus the trailing 'and '
$stmt= substr($searchStmt, 0, strlen($searchStmt)-4) ;
But what I really need is to be able to search a broader section of the DB.
This works great if the user only selects one variable for each search
term...but how do I write it if they need to be able to select *multiple*
variables?
I guess multiple variables are an array...but I can't envision what to do
with it...
thanks,
John Corry