Cagecrawler Posted September 29, 2007 Share Posted September 29, 2007 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"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/71051-if-statement/page/3/#findComment-357654 Share on other sites More sharing options...
le007 Posted September 29, 2007 Author Share Posted September 29, 2007 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... Quote Link to comment https://forums.phpfreaks.com/topic/71051-if-statement/page/3/#findComment-357657 Share on other sites More sharing options...
le007 Posted September 29, 2007 Author Share Posted September 29, 2007 You get the URL? Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/71051-if-statement/page/3/#findComment-357663 Share on other sites More sharing options...
Cagecrawler Posted September 29, 2007 Share Posted September 29, 2007 Yeah, I've PMed you with a solution. Basically, to use my code all you need to do is add [] to your select name so it passes an array of all of the chosen property types. Quote Link to comment https://forums.phpfreaks.com/topic/71051-if-statement/page/3/#findComment-357664 Share on other sites More sharing options...
le007 Posted September 29, 2007 Author Share Posted September 29, 2007 Thanks buddy I replied, still no joy... Quote Link to comment https://forums.phpfreaks.com/topic/71051-if-statement/page/3/#findComment-357668 Share on other sites More sharing options...
le007 Posted September 29, 2007 Author Share Posted September 29, 2007 Still nothing happening with this prob, any ideas anybody? Quote Link to comment https://forums.phpfreaks.com/topic/71051-if-statement/page/3/#findComment-357920 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.