Hello,
I have several categories I am quering from, one of the options (stored as a category in my category table) is All Categories.
I am now able to query for a particular query. The category is selected by the user and I use $_GET to query. This is working fine.
What I would like to do is, when a user selects All Categories from the category option, the query should leave the cagtegory clause in the query and return all results.
How do I do nested queries in PHP?
Here is how my code for query looks now:
$query2 = "SELECT ccode, category_name, phone, address, city, state, category from category_details, category, city, state where state.id = category_details.fk_state and city.id = category_details.fk_city and category.id = category_details.fk_category and category = '{$_GET['category']}' and city = '{$_GET['city']}'";
I would like to have a nested query which first checks (using $_GET) to see if "All Categories" is clicked by the user, if it is clicked then have a query similar to the above just loosing the category part, if other category is clicked, use the above query.
Please help me with this nested query.
Appreciate your help.
Thanks in advance.