title: Using Ajax with multiple select
body: <p>I have a multiple select form that I am now trying to use with AJAX. The drop down is supposed to act as a filter for images.</p>
  
  <p>Index.php</p>
  
  <pre><code>&lt;script&gt;
  function filterResults(str)
  {
  if (str=="")
    {
    document.getElementById("divResults").innerHTML="";
    return;
    } 
  if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
  else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  xmlhttp.onreadystatechange=function()
    {
    if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
      {
      document.getElementById("divResults").innerHTML=xmlhttp.responseText;
      }
    }
  xmlhttp.open("GET","filter_ajax.php?filter="+str,true);
  xmlhttp.send();
  }
  &lt;/script&gt;
  
  &lt;form action="" class="css_form" id="picture_filter" name="picture_filter"&gt;
      &lt;select onchange="filterResults(this.value)" multiple="multiple" name="filter[]" id="filter"&gt;
       &lt;option value="filter_name_1"&gt;Filter name 1&lt;/option&gt;
       &lt;option value="filter_name_2"&gt;Filter name 2&lt;/option&gt;
       &lt;option value="filter_name_3"&gt;Filter name 3&lt;/option&gt;
       &lt;option value="filter_name_4"&gt;Filter name 4&lt;/option&gt;
  &lt;/select&gt;
  &lt;div id="divResults"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>and filter_ajax.php</p>
  
  <pre><code>&lt;?php
  
  include ("connect.php");
  
      $filter = $_GET["filter"];
      $filterIn = implode("','",$filter);
  
          $result = mysql_query("SELECT * FROM edt_images
                                  WHERE category1 IN ('$filterIn')
                                  OR category2 IN ('$filterIn')
                                  OR category3 IN ('$filterIn')
                                  OR category4 IN ('$filterIn')
                                  OR category5 IN ('$filterIn')
                                  OR category6 IN ('$filterIn')")
              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>In my database each image has six entries which correspond to the categories, and are filled with subcategories. Thus whats supposed to happen is that when an item is selected from the "filter drop-down" it should query each six columns for that information. However I am receiving the following error and output:</p>
  
  <p>implode(): Invalid arguments passed in ... Line 6. </p>
  
  <p>For testing I have five entries. 3 which have all information filled in for the six categories entries, and two which were left blank. </p>
  
  <p>The two that are left blank are always returned with the error above.</p>
  
  <p>Anyone have any ideas as to why this is happening? </p>
  
  <p>Thanks in advance</p>