I’m trying to pull multiple rows from a single table. I’m trying to pull either all males or all females in different zip codes.
<?php
$zipCodes = array("55555", "66666", "77777", etc...);
$fetchUser = mysql_query("select * from users where gender = '$_POST[gender]' ".implode(" or zipCode = ", $zipCodes)." order by id desc");
while($var = mysql_fetch_array($fetchUser)) {
code...
}
?>
You should use
INon this,currently your code is vulnerable to SQL Injection. Please read on PDO or MySQLI extension.
Read more on this article: Best way to prevent SQL injection in PHP
PHP PDO: Can I bind an array to an IN() condition?