Presto-X Posted June 30, 2008 Share Posted June 30, 2008 Hello everyone, So I’m stumped on how to pull this off, I’m working on a real estate site and I need to filter a list of properties based on two columns called “zone” and “lease_sale”. The pages right now are filtering based a column called “lease_sale” this column holds one of two options “lease” or “sale”. We have two pages “Properties for Lease” and a “Properties for Sale” page. I have 4 checkboxes at the top of my two pages that are checked and I want the filter to load all of the properties that fall in to one of these 4 zones: land, retail, office, industrial. When you uncheck a box and click the filter button we don’t want the unchecked zone to be included in the page query any more. Any help anyone can offer would be great! Thanks guys. Link to comment https://forums.phpfreaks.com/topic/112552-help-making-a-multiple-checkbox-filter/ Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 is the data coming from a database? if it is then you can work this within the query. Link to comment https://forums.phpfreaks.com/topic/112552-help-making-a-multiple-checkbox-filter/#findComment-578009 Share on other sites More sharing options...
Presto-X Posted July 7, 2008 Author Share Posted July 7, 2008 So this is the query I'm trying to get to work (mysql): $query_properties = sprintf("SELECT * FROM jos_property WHERE lease_sale = %s AND zone = %s OR zone = %s OR zone = %s OR zone = %s", GetSQLValueString($colname_properties, "text"),GetSQLValueString($retail_properties, "text"),GetSQLValueString($office_properties, "text"), GetSQLValueString($industrial_properties, "text"),GetSQLValueString($land_properties, "text")); Ok what I'm wanting the query to do is get only the property that is ether for sale or lease, then using the filter from the url only get what is checked, land, retail, office, industrial. The link/url's look like this: index.php?option=com_property&lease_sale=sale&retail=1&office=1&industrial=1&land=1 The problem that I'm having is that it's pulling both for lease and for sale, but if I take out the filters and use this code $query_properties = sprintf("SELECT * FROM jos_property WHERE lease_sale = %s", GetSQLValueString($colname_properties, "text")); It will only pull for lease or for sale like I want but with out the other zone filters, how do I get my query to do both? Link to comment https://forums.phpfreaks.com/topic/112552-help-making-a-multiple-checkbox-filter/#findComment-583965 Share on other sites More sharing options...
Presto-X Posted July 7, 2008 Author Share Posted July 7, 2008 Ok I think I just found the awser: I needed to use brackets to group my filters like so: SELECT * FROM jos_property WHERE lease_sale = %s AND (zone = %s OR zone = %s OR zone = %s OR zone = %s) It seems to be working now. Link to comment https://forums.phpfreaks.com/topic/112552-help-making-a-multiple-checkbox-filter/#findComment-583973 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.