Jump to content

Help Making A Multiple Checkbox Filter


Presto-X

Recommended Posts

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

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?

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.