Results 1 to 2 of 2
Thread: Problem with searchform
Mar 12, 2013, 16:58 #1
- Join Date
- Nov 2012
- 0 Post(s)
- 0 Thread(s)
Problem with searchform
I have a searchform where you can search for properties. Right now it only works if you fill in all the fields. But how would I do if I want to eg leave a field blank and just search the rest, or just search one field and leave the rest blank?
This is the code for the query I have today:
$sql = mysql_query("
WHERE (rooms LIKE '%$room%' OR '$room' = '')
AND (status LIKE '%$status%' OR '$status' = '')
AND (type LIKE '%$type%' OR '$type' = '')
AND (adress LIKE '%$county%' OR '$county' = '')
AND (area LIKE '%$area%' OR '$area' = '')
AND (price BETWEEN '$min' AND '$max')
") or die(mysql_error());
Thanks in advance!
Maybe you should note that all the fields are select fields, not text fields.