I am trying to make a property site where users search by location, number of rooms and/or price
however I only want the fields to appear in the SQL if they have been used, so for example if they only enter something in the location field the sql would be
if the enter 2 fields, say rooms
and on
I am using GET to pass the query and I am guessing I need to do some kind of string to make this work but have no idea how
however I only want the fields to appear in the SQL if they have been used, so for example if they only enter something in the location field the sql would be
Code:
SELECT * FROM villadesc WHERE location='$location'
if the enter 2 fields, say rooms
Code:
SELECT * FROM villadesc WHERE location='$location' AND rooms='$rooms'
I am using GET to pass the query and I am guessing I need to do some kind of string to make this work but have no idea how