I have a query that I'm having problems with, and I believe the problem is in my syntax.
Here is the breakdown.
I have a file with 2 selectable options (city / type), which in turn does a search of the database.
1) If only the "city" is set, I need the search to only bring up results matching to the "city" option selected.
2) If only the "type" is set, I need the search to only bring up results matching to the "type" option selected.
3) If both are set, I need the search to bring up results matching both options.
I've never done a multi-option query like this before, but this is what I have right now is this.
CODE
$search = mysql_query("SELECT * FROM info WHERE (type = $type) OR (city = $city) OR ((type = $type) AND (city = $city)) ORDER BY 'pk' ");
When I try and bring up the results in a loop:
CODE
while($rowInfo = mysql_fetch_assoc($search))
I get the following error.
CODE
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource
referencing the line of code I included immediately above.
I've tried to echo the $search results of the mysql_query, and nothing is coming up, so I believe it's a problem with the syntax of my query itself.
I'm hoping someone can steer me in the right direction.
This post has been edited by Arhineus: 14 Jun, 2008 - 03:20 PM