views:

49

answers:

1

Hi,

Im trying to create a query filter system in codeigniter. Basically, within a particular query, Id like to be able to send a list of values returned by the main query (working with items for sale on different sites, so for instance, price, and website), output them to my sidebar, and then be able to drill down the results via the values in the sidebar. (thefind.com is a great example on what im trying to do).

Ive been trying to wrap my head around exactly how to do this all day, but no luck. If anyone could push me in the right direction it would be much appreciated. P.S. im using DMZ datamapper object oriented code igniter extension library, so I figure that might help to make it easier?

A: 

If I understand your question correctly this could be simpler than you think. Think of each filter category and value (ie price, amount) as a key=>value pair you can use in a 'where' clause. If in your first query you select all based on the initial criteria, when a user adds a filter you simply add a 'where' clause based on what they've selected and run the query again. That's what I would do using a db. If in your case you're grabbing data from all over the place why not store the complete data set in a temporary table in your db then run queries on that?

musoNic80
Well ya that partially answers it thanks. I guess my main problem is figuring how I would structure this type of querying in code igniter. Because for each set of results, there will be a unique set of filters which need to be returned. So Im trying to understand the best way to create the filters in a sidebar dynamically, based on the current query
thrice801
When you say "unique set of filters" do you know what they will be or could they be anything? If you are expecting a finite set of initial results each with a defined set of filters then you could store all of this in a config file and then use a simple switch statement to return the correct set of filters based on the initial result. Think of Amazon; the filters are different for each product category but are pre-defined for that category.Is this closer to what you need?
musoNic80