I need to somehow get the in array function into the mysql query along with the price from, price to etc so that I can limit the results and do the pagination. If anyone could help that would be great.
Code: Select all
if ($ssuburb!='')
{
$query .= " suburb = '".$ssuburb."' AND";
}
if ($sbedrooms!='')
{
if ($sbedrooms!='5')
{
$query .= " bedrooms = '".$sbedrooms."' AND";
}
else
{
$query .= " bedrooms >= '".$sbedrooms."' AND";
}
}
if ($sbathrooms!='')
{
if ($sbathrooms!='5')
{
$query .= " bathrooms = '".$sbathrooms."' AND";
}
else
{
$query .= " bathrooms >= '".$sbathrooms."' AND";
}
}
$ret = "SELECT * FROM listings WHERE ".$query ." id != '' ORDER BY $order";
//echo $ret;
$result = mysql_query($ret) or die("Query failed : " . mysql_error() . mysql_errno());
$i = 0;
while ($listing = mysql_fetch_array($result))
{
$array= explode(',', $listing['category']);
if (in_array($spropertytype, $array) && $listing['price'] >= $spricefrom && $listing['price'] <= $spriceto || $spropertytype == '' && $listing['price'] >= $spricefrom && $listing['price'] <= $spriceto)
{
RESULTS HERE
$y='list'; //A listing has been made ... This tells the if below to display the no result text
}
if (!in_array($spropertytype, $array) && $i == '0' || $y != 'list')
{
echo "<center>Unfortunately your search returned no listings</center>";
}
}
