I’m looking for a good way to do a search using CodeIgniter and multiple filter parameters with checkboxes. To keep it simple, imagine this:
[X] T-shirts
[ ] M
[ ] L
[X] XL
[ ] Pants
[ ] M
[ ] L
[ ] XL
A page displays all avalible clothes in the store (get_all).
You can use a checkbox to display only the t-shitrs.
I’ve gotten this far with something like this /clothes/type/t-shirt
but now within the t-shirts I want to display the L and XL sizes (two checked checkboxes).
I don’t to use pull-down menus, because I want to be able to display all sorts of combinations, for example size L t-shirts and XL pants at the same time.
Eventually I would like this to be an AJAX based search, so a POST would be better than URI based search.
What’s the best way to implement something like this?
Create this form. Repeat the fieldset for each product type (this example shows tshirt):
The ‘active’ key is not used, but it makes sure the producttype key exists when no options are selected.
The controller method will differ whether you use separate tables for each product type, or just put them all in one table. Since the first is more difficult, here goes:
Please note: this is pretty insecure. Make sure the user’s input is valid.