title: MySQL WHERE from an array
body: <p>I have an array with these values, 1 &amp; 5 and I am trying to generate a mysql query to return all of these values id, I hope that makes sense, here is my code:</p>
  
  <pre><code>if(isset($filterOpts['location'])){
                          foreach($filterOpts['location'] as $row =&gt; $value){
                                  $where .= " AND `rb_locations`.`locationId` = " . $value;
                          }
                  }
  </code></pre>
  
  <p>this will return AND <code>rb_locations</code>.<code>locationId</code> = 1 AND <code>rb_locations</code>.<code>locationId</code> = 5</p>
  
  <p>I am guess that AND and AND are causing my problems. how do I fix this? When I remove the 5, it returns results.</p>
  
  <p>I didnt post the rest of the query because I know its not the issue :)</p>
  
  <p>Any suggestions on how to fix this?</p>