title: multiselect query db
body: <p>I overthought a recent post and deleted it. Hopefully this version is a little clearer.</p>
  
  <p>I have a multiselect dropdown, which I want to be able to filter a database table with.</p>
  
  <p>So if I have the following drop down with roughly 70 entries:</p>
  
  <pre><code>&lt;select multiple="multiple" id="filter" name="filter"&gt;
    &lt;optgroup label="category1"&gt; &lt;!--jquery ui plugin allows for grouping --&gt;
      &lt;option value="sub1"&gt;Subcategory 1&lt;/option&gt;
      &lt;option value="sub2"&gt;Subcategory 2&lt;/option&gt;
      &lt;option value="sub3"&gt;Subcategory 3&lt;/option&gt;
    &lt;/optgroup&gt;
    &lt;optgroup label="category2"&gt;
      &lt;option value="sub4"&gt;Subcategory 4&lt;/option&gt;
      &lt;option value="sub5"&gt;Subcategory 5&lt;/option&gt;
      &lt;option value="sub6"&gt;Subcategory 6&lt;/option&gt;
  </code></pre>
  
  <p>...
      </p>
  
  <p>And I have 6 categories I need to search through in my sql statement, thus so far I have:</p>
  
  <pre><code>&lt;?php
      include ("connect.php");
  
      $filter = $_POST["filter"];
  
          $result = mysql_query("SELECT * FROM edt_images
                                  WHERE category1= '$filter'
                                  OR category2= '$filter'
                                  OR category3 = '$filter'
                                  OR category4 = '$filter'
                                  OR category5 = '$filter'
                                  OR category6 = '$filter'")
              or die(mysql_error());
          while ($row = mysql_fetch_array($result)) {
              echo "&lt;img src='files/small/thumb0_".$row['item_name'].".".$row['file_extension']."' border='0'/&gt;"; 
          }
  ?&gt;
  </code></pre>
  
  <p>Right now it works if I only select one item from the dropdown because it searches the six columns for that entry. So my question is how would I search these six columns for multiple entries?</p>
  
  <p>Thanks in advance</p>