kproc
02-07-2007, 08:48 PM
Below is could that Im trying to use to create an advance search.
the values for all categories except title are select menus. the problem is the below returns all enteries. Its not narrowing it down based on the the conditions set.
If on field is blank then I want it to be omitted from the query and use the other criteria set by the user any help is excellent
if(isset($_POST['advanceSearch'])){
$title = $_POST['title'];
$ad_type = $_POST['ad_type'];
$category = $_POST['category'];
$sub_category = $_POST['sub_category'];
$query_advance_ads = ("SELECT * FROM ads WHERE title LIKE '%$title%' OR category = '$category' OR sub_category = '$subcategory' OR ad_type = '$ad_type'");
$sql_advance_ads = mysql_query($query_advance_ads)or die("SQL Error: $query_advance_ads<br>" . mysql_error());
}
?>
the values for all categories except title are select menus. the problem is the below returns all enteries. Its not narrowing it down based on the the conditions set.
If on field is blank then I want it to be omitted from the query and use the other criteria set by the user any help is excellent
if(isset($_POST['advanceSearch'])){
$title = $_POST['title'];
$ad_type = $_POST['ad_type'];
$category = $_POST['category'];
$sub_category = $_POST['sub_category'];
$query_advance_ads = ("SELECT * FROM ads WHERE title LIKE '%$title%' OR category = '$category' OR sub_category = '$subcategory' OR ad_type = '$ad_type'");
$sql_advance_ads = mysql_query($query_advance_ads)or die("SQL Error: $query_advance_ads<br>" . mysql_error());
}
?>