I am creating a custom ecommerce system for a client who sells custom grad gear. I have the following screen shot of my product layout…

I have the form on the right side of the page that has a max price, colors and materials. When you click the Update options it sends all the data via jquery’s ajax function over to my codeigniter controller where i need to pull a new list of products with the options that they have selected and within the price range they have selected. I then pass the products array to a codeigniter view and return the view to the cart with the ajax success variable.
So I can get this working with just colors, or just materials, but my problem is figuring out how to pull a set of products that has all of the materials and options I need. I guess I just can’t wrap my brain around the best way to do it. I thought about pulling a list with the correct colors, then a list with the correct materials, then a list with the correct pricing and then deleting duplicates in a merged array, but it just doesn’t feel like thats the best way to do it.
This particular client only needs “color” and “material” as an option so my products table is set up to have the id of the color and the id of the material all in the products table. Then I have a colors and materials table with the id and the color or the id and the material.
What are you guys thoughts on the best way to do this? I’d like to use codeigniters active record to do the mysql stuff.
///// EDITS ///////////////////////////////////////
Here is an image of my product Tables:

Also, here is my jquery controlling the submit of data to the codeigniter controller:
//Filter Options Ajax
$(‘#updateOptions’).click(function(event) {
//Prevent the default href action
event.preventDefault();
var filterOptions = $('#filterForm').serialize();
//Get the site url
var siteUrl = $('#siteUrl').val();
//Roll up the product listing div and show a loader
$('div.products').slideUp( 500, 'easeInExpo' );
$('div.loader').delay(500).fadeIn();
//Get a new list of products and repopulate the information
$.ajax({
type: "POST",
url: siteUrl + "category/filterProducts",
data: { filterOptions: filterOptions },
success: function(data) {
$('div.loader').fadeOut(500);
$('div.products').html(data).delay(500).slideDown( 500, 'easeOutExpo' );
}
});
});
Something like this:
Then the url
prices.php?min_price=100would addWHERE price < 100to your query.For colors (I’m using
|for a delimiter, but use what works for you):Then the url
prices.php?min_price=100&colors=red|bluewill addIf you are posting your colors using an array (checkboxes) try this:
This lets you use the url or the POST to add your colors, depending on how you’re doing things.