title: PHP PDO: SELECT array within IN()
body: <p>I am a little late to the game and am trying to transition to PDO from mysql_* while trying to tackle a current challenge.  I have an interface where I capture box number values within an array and that array is stored in another array by line item (for clarity purposes these are nested arrays).</p>
  
  <p>My main purpose is to take the box numbers for a particular line item and run a mysql select query to return the number of units in that given set of boxes.  If the qty in the boxes is not the quantity the user thinks there are I want it to throw an error.</p>
  
  <p>Currently my challenge is I'm getting an empty result set.  I believe this to be due to my array of box numbers not being properly passed to the PDO select statement.  Any thoughts or guidance would be much appreciated.</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>$Boxes = $_POST['Boxes']; //this includes box numbers within an array for each line item of a form
  
  $e = 0;
  
  while($e&lt;$num1){
  $units = 0;
  $r = 0;
  $SO_Line_Item=mysql_result($result1,$e,"SO_Line_Item");
  
      foreach ($Boxes[$e] as $a =&gt; $b)  // the purpose of this loop is to take the values from Boxes and store it in $zzz which I hope to use in my Select statement below.
      {
      $zzz[] = $Boxes[$e][$r];
      $r++; 
      }
     //end inner foreach
  
  $BNs= implode(',', $zzz);
  
  $db = new PDO('mysql:host=XXXXXX ;dbname=XXXXXX', $dbuser,$dbpass);
  $stmt = $db-&gt;prepare("SELECT Box_Num,Timestamp,SN,Assy_Status FROM Current_Box WHERE Box_Num IN(' . $BNs . ')");
  $stmt-&gt;execute($zzz);   
  
  $results = $stmt-&gt;fetchAll(PDO::FETCH_ASSOC);
  var_dump($results); // this shows up as an empty array
  
  }  
  $e++;
  }
  </code></pre>