Jump to content

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

Top Posters In This Topic

Top Posters In This Topic

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • 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.