I want my search bar to find specific properties based on the parameters the user enters. This is my code so far:
if (isset($_POST["Search"])) {
$SearchInput = $_POST["Search"];
$SearchInput = trim($SearchInput);
$SearchInput = stripslashes($SearchInput);
$SearchInput = htmlspecialchars($SearchInput);
$price1=$_POST['amount1'];
$price2=$_POST['amount2'];
if ($CH == 'on' || $CF == 'on') {
$critera .= " AND (street LIKE '%" . $SearchInput . "%' OR postcode LIKE '%" . $SearchInput . "%') AND price BETWEEN '$price1' AND '$price2'";
}
else{
$critera .= " AND type='House' AND (street LIKE '%" . $SearchInput . "%' OR postcode LIKE '%" . $SearchInput . "%') AND price BETWEEN ('$price1' AND '$price2')";
}
}
if ($SearchInput == ''){
$query = "SELECT * FROM property WHERE type='House' AND city='Sheffield' AND price BETWEEN ('$price1' AND '$price2') Order By postcode ASC";
}
else {
$query = "SELECT * FROM property WHERE city='Sheffield'" . $critera . " Order By postcode ASC";
}
}
No matter how I order the operators it either ignores the type='House' parameter or ignores the price parameters.