title: Product filtering with MySQL and PHP for opencart
body: <p>I am trying to make dynamic product filtering for opencart in which user could add filters, assign them to categories and assign filter values for products.</p>
  
  <p>Currently I Have these mysql tables: </p>
  
  <ol>
  <li>Filters - ID NAME  </li>
  <li>Filters_categories - ID FILTER_ID CATEGORY_ID</li>
  <li>Filters_values - ID FILTER_ID VALUE</li>
  <li>Filters_products - ID FILTER_ID VALUE_ID PRODUCT_ID</li>
  </ol>
  
  <p>The problem is with this structure that i can't get products when more than one filter is activated because i get MySQL query which looks something like this:</p>
  
  <pre><code>SELECT product_id FROM Filters_products WHERE ((name_id='1' OR name_id='2') AND filter_id='1') AND ((name_id='3' OR name_id='4') AND filter_id='2')
  </code></pre>
  
  <p>And it doesn't make any sense. I can't figure out how should i change my database structure to make dynamic filtering possible. How can I solve this situation? 
  Thank you.</p>