Problem with searchform

Hello!

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("
SELECT *
FROM property
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.

<?php

$valid = FALSE;
$sql = "SELECT *  
FROM property 
WHERE (";
if(isset($room)) { 
    $sql .=  " rooms LIKE '%$room%' AND ";
    $valid = TRUE;
}
if(isset($status)) { 
    $sql .=  " status LIKE '%$status%' AND ";
    $valid = TRUE;
}
if(isset($county)) { 
    $sql .=  " county LIKE '%$county%' AND ";
    $valid = TRUE;
}
if(isset($area)) { 
    $sql .=  " area LIKE '%$area%' AND ";
    $valid = TRUE;
}
if(isset($min) AND isset($max)) { 
    $sql .=  " price BETWEEN '$min' AND '$max' AND ";
    $valid = TRUE;
}
if($valid == FALSE) { die("bad query"); }
$sql = substr($sql, 0, -4);  // drop last AND
$sql .= ")";

$result = mysql_query($sql) or die(mysql_error()); 

?>