here is the error statement:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND bed = '' AND bath = '' AND garage = ''' at line 1
here is part of the code that its talking about:
$sql = "SELECT * FROM homes WHERE models LIKE '%$search%' LIMIT $from, $max_results";
if ($_POST['bed'] != "any") {
$sql .= " AND bed = '".$bed."'";
}
if ($_POST['bath'] != "any") {
$sql .= " AND bath = '".$bath."'";
}
if ($_POST['garage'] != "any") {
$sql .= " AND garage = '".$garage."'";
}
This is part of my search.php page and these three parts are used as a drop down menus in a search form.
such as this....
<select name="garage">
<option value="any" selected>any</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select>
My problem is that I just added a pagination code to my script and now it doesn't like the coding for the three options. Before the pagination script it worked perfectly.
How can i make this code better with no errors?
here is the code in action...
http://www.gatorwire.com/page/