I have 2 drop down lists on a page that when the form is submitted will query 2 fields using AND.
Example:
user selects FORD from Manufacturers and SUV's from category.
I actually have a script working that works when a user selects specific criteria.
However, if I they select All manufacturers or All Categories, no results are returned.
Here's my query.
$query = "select * from products where manufacturer = '". $mfr ."' and category = '". $cat ."'";
Reasons for why it looks the way it does.
It seems that if I didn't use the ' then I was given an error:
Warning: Supplied argument is not a valid MySQL result resource in line 64
so surrounding the $mfr and $cat with ' seemed necessary.
Problem with that is when they select all, $mfr or $cat is set to
so the query looks like select from products where manufacturer = '' and category = '' and it isn't returning any results.
Can you tell I'm slightly new to php and mysql?
I have books and done searches but nothing seemed to cover my specific problem.
I think I can make it work with a couple of if/else if statements, but if I can find a solution with the one line instead, it would be easier.
Thanks in advance for any help.