Well if you pick 3 you mean “with 3 bathrooms”.
SELECT pid, address
FROM properties
WHERE 1=1
AND district = "kandy"
AND bedrooms = 3
AND bathrooms = 3
Well, as the answer to your original question can get very complicated very fast, I am happy to deal with this simple enough query for now.
Your query builder starts off with a string…
$select = "SELECT pid, address FROM properties WHERE 1=1";
to which you add all the incoming POST elements;
(I am leaving out all filtering, error checking and sanitization for the moment)
$and_clauses = "";
foreach( $_POST as $key=>$value){
$and_clauses = " AND $key= '$value'";
}
Put those together and you should have your target query:
echo $select.$and_clauses;
And that is just a little example of how you could make a basic “query builder”.
It is not perfect, it is not secure, it does not cover all of your cases - it is totally dependent upon all of your clauses being this = that, it incorrectly quotes integers, but Mysql forgives that and should run your query all the same.
As is you should be able to add other clauses to the POST array and get differing results.
Have a play with that, think about how your form would have to evolve and change, including the comments about your form made by Michael and come back with your questions.