Forum Moderators: open
I'm trying to do this:
$query ="SELECT * FROM $sn WHERE name LIKE $var OR category LIKE $var AND zip = $zipcode ORDER BY name";
When I run this query, I get all names like $var from $sn. I don't get the category names like $var or the names only with $zip.
If I remove the AND zip = $zipcode, and run the query I get all names and categories like $var.
I want to select all names and categories like $var with the zipcode $zipcode.
Any ideas?
I want to add on another piece of filtering
$query ="SELECT * FROM $sn WHERE (((name LIKE \"%$trimmed%\") OR (category LIKE \"%$trimmed%\")) AND ((city LIKE \"%$czt%\") OR (zip = $czt))) ORDER BY name";
I have 2 input fields where a user can type in a name or category, and a city or zip.
the above query doesn't work. It works if I put in a name or category with zip, but not a name or category with city.