I'm new to php and mysql so I need some help with my query. This is my sql query
SELECT * FROM table1 WHERE (Name LIKE '%$keyword%' OR ZipCode LIKE '%$keyword%') AND Category LIKE '$category' AND Country LIKE '$country' LIMIT $start, $limit
Now what I want to do exaclty is
- This query should search column names with Name or ZipCode using a text field with the name keyword. That is either keyword matches the Name column or the ZipCode.
- The query should also work if no keyword is entered and only a country is selected from a dropdown.
- The query should also work if no keyword or country is input and only a category is selected from a dropdown.
In more simple words if either of the things keyword, country or category is selected the search should display results accordingly. Moreover it should also work if all the fields are input. I managed to do half of it but sometimes it gives me wrong results. Please help.