title: E-commerce products filter
body: <p>Im trying to biuld a filter algorithm for my product list.</p>
  
  <p>For example I have 2 Televisions.</p>
  
  <p>First one is:  screen Size 117 Cm, brand Samsung.
  Second one is: screen size 203 CM, brand Sharp.</p>
  
  <p>And i have the following filters:</p>
  
  <p>Brand: Samsung, Sharp</p>
  
  <p>Screen size: 117 Cm, 203 CM</p>
  
  <p>If I want to see only Samsung TVs and I check the Samsung Filter, how can I reach to conclusion that I should remove Screen size 203  from filters, because samsung have only 117 cm tv.</p>
  
  <p>But if i check sharp tv and samsung in the same time, then I should see both screen size filters.</p>
  
  <p>I m asking for an idea for some php/mysql algorithm.</p>
  
  <p>I hope you understand what i m asking.</p>
  
  <p>For an example look here: <a href="http://www.ebay.co.uk/sch/Televisions-/11071/i.html?_dcat=11071&amp;Display%2520Technology=LED%2520LCD&amp;rt=nc" rel="nofollow">http://www.ebay.co.uk/sch/Televisions-/11071/i.html?_dcat=11071&amp;Display%2520Technology=LED%2520LCD&amp;rt=nc</a></p>
  
  <p>The website knows how many products it has have before user checks any filter: eg: "40" - 49"  (326)) -> they know that they have 326 products before user checks that filter.</p>
  
  <p>In short : The checkboxes you check in the filters, should be disabled if the combination is not available for the products.</p>
  
  <p>I have 3 tables: 
  products(id_product,name), 
  filters(id_filter,name,id_category), 
  filters_values(id,id_product,id_filter,value) </p>
  
  <p>In my product_list page it should appear only filter that once being checked they return products.</p>
  
  <p>My first thought is to make sql from each filter value combination. Eg 10 filters with 4 values: 40 sql, just to check if filters return products, But this is way to much stress on db </p>
  
  <p>For example if I have one filter with 4 values, i should make 4 query in order to see if I have products on specific value.</p>
  
  <p>I i have 10 filter each having 4 values i should do 40 sql query. Which is a lot.
  How can i do this faster?</p>
  
  <p>Thanks</p>