I submit the price and category_id through a form and then the query shows me the results. What I have is this below.
$s = mysql_real_escape_string($_GET["s"]);
$c = mysql_real_escape_string($_GET["c"]);
SELECT COUNT(id) FROM products WHERE price <= '$s' AND category_id = '$c'
When a user does not select any category and the value of it is blank, there is nothing displayed. How can I fix the query that if $c does not have any value ignore the AND category_id = '$c' ?
I thought to create a second query for this purpose, but is there any other way ?
Something like this should work: