Jump to content

If statement


le007

Recommended Posts

This method doesn't quite fit what you need but is a better way of doing it IMO.  You need each of the property types as a checkbox in your form with it's name as an array.  When passed to this bit, if none have been chosen an array won't be initialised when you set $prop_type.  You can use this to allow each property type to be independantly chosen - the user can choose as many of the choices as they like.

<?php
if(!is_array($prop_type)) //No choices have been selected
{
$sql = "SELECT * FROM `cheap_tabl` WHERE (`property_type` like 'House' OR `property_type` like 'Site') and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
}
else //Some choices have been chosen
{
$sql = "SELECT * FROM `cheap_tabl` WHERE (`property_type` IN ('".implode("','",$prop_type)."')) and `area` like '$county' and `town_city` like '$town' and `price` > ($minprice + 1) and `price` < ($maxprice + 1) and `bedrooms` > ($minbeds - 1) and `bedrooms` < ($maxbeds + 1) ORDER BY cheap_id DESC LIMIT $from, $max_results";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/71051-if-statement/page/3/#findComment-357654
Share on other sites

  • Replies 55
  • Created
  • Last Reply

teng84, I dunno really how to do that case to incorporate it and cagecrawler easiest thing for both of you is to check out the link I'll pm you and maybe then you'd have a better idea? If you just leave property type as "All property types" you'll see what I mean, house and site are only meant to come up but everything does, 295 properties...

Link to comment
https://forums.phpfreaks.com/topic/71051-if-statement/page/3/#findComment-357657
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.