So, Im doin okay, thus far, but now I need to query several more things simulatniously, all of which have a 'no preference' value.
For instance, number of bedrooms, property type, and several checkboxes which if checked indicate a feature the buyer feels is essential, like a garage, or off street parking. But I seem to be having two major problems;
1. I cant seem to add another element into that query without it outputting an error
and
2. I dont know how to tell it that if no preference is selected, it should ignore that particular variable and show all properties that conform to the other variables.
$query = ("SELECT * FROM propertys WHERE MATCH(Location) AGAINST ('$location') AND (`Rent (monthly)`) BETWEEN ('$minrent') AND ('$maxrent')");
$result = mysql_query($query);
if ($location ==("searchpostcode")) {
$query = ("SELECT * FROM propertys WHERE Postcode LIKE '%$postcode%' AND (`Rent (monthly)`) BETWEEN ('$minrent') AND ('$maxrent')");
$result = mysql_query($query);
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
echo "<table cellpadding=10 border=1>";
while($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td>".$row[0]."</td>";
echo "<td>" . $row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "</tr>";
}
echo "</table>";
}
else {
// no
// print status message
echo "No records found!";
} }
else
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
echo "<table cellpadding=10 border=1>";
while($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td>".$row[0]."</td>";
echo "<td>" . $row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "</tr>";
}
echo "</table>";
}
else {
// no
// print status message
echo "Nothing found!";
}
mysql_close($dbh);
?>