I have a field on a real estate search form asking for Min to Max number of bedrooms. The PHP query extract to return the search results is;
//check bedrooms
if(!empty($_GET["room_no_min"]) && is_numeric($_GET["room_no_min"])){
$query[] = "'No_Bedrooms' >= '".$_GET["room_no_min"]."'";
$room_min_val = $_GET["room_no_min"];
}
if(!empty($_GET["room_no_max"])){
$query[] = "'No_Bedrooms' <= '".$_GET["room_no_max"]."'";
$room_max_val = $_GET["room_no_max"];
}
Which is fine, but I want it to take into account if someone enters the value 5 (min) to 2 (max) i.e. the other way round than they are suppose to. I don't want to use validation I'd rather the query could be something like from =>min(room_no_min,room_no_max)
and <= max(room_no_min,room_no_max)
but not sure how to re-write the query.