Hi Fenway,
That's where I get confused. I wanted to just put it all in one query string, but I don't know how to distinguish between ANDs and ORs for something like that?
Here's an example I'm currently using:
if(isset($_POST['director'])) $director = "DIRECTOR = '$_POST['director']"
if(isset($_POST['terms']))
{
$term_in = explode(" ",$_POST['terms']);
foreach($term_in as $k=>$v)
{
$terms .= "OR $terms LIKE '%$v%'";
}
$terms = ltrim($terms,"OR");
}
else
{
$terms = "";
}
foreach($_POST['genre'] as $genre_key=>$genre_category)
{
if(isset($genre_category)) $genre = "OR $genre_category='1'";
}
$genre = ltrim($genre,"OR");
"SELECT * FROM listings WHERE $director $terms $genre ORDER BY title ASC";
But obviously the ANDs and ORs get screwy...
More help, please?
Benny
[!--quoteo(post=333723:date=Jan 5 2006, 06:14 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Jan 5 2006, 06:14 PM) 333723[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Well, you need to first determine which conditions have been inputted (in PHP), and make a (possibly) combined query that, in principle, can include all three. Usually, this requires JOINing an extra table for each addition condition, and updating the WHERE clause accrodingly. I built the query string in middleware, and then run the query. Why don't you post what you have for each _individual_ query, and then try and combine them.