I have a search form that contains 3 dropdown boxes:
Each of these boxes contain values which will get info from a database when submitted, but they also have a value called [no preference], this is selected when the user doesn't want to search for any particular value.
When submitted it goes through to a page which has a MYSQL SELECT statement:
$query = "SELECT * FROM property_details WHERE area = '$search_area' AND price = '$search_price' AND bedrooms = '$search_bedrooms'";
What I need to know is if the user selects [no preference] on any one of the dropdowns, how can I make the above SELECT statement not include that in the search, but still search on the other criterias.
(e.g. if in the search_bedrooms dropdown I selected [no preference], how could it be excluded from the search, but still include area and price?)
I know it can be achieved with multiple SELECT statements, but there has to be a more efficient way.
Hope that makes sense.
Many thanks in advance.