PHP the SELECT FROM WHERE col IN no working using array
- by Sam Ram San
I'm trying to pull some data from MySQL using an Array that was fetch from a first query.
Everything's fine all the way to the implode after that, it's been a headache for me.
Can someone help me?
<?php
$var = 'somedata';
include("config/conect.php");
$zip="SELECT * FROM table WHERE firstcol LIKE '%$var%' ORDER BY seconcol";
$results = $connetction->query($zip);
while ($row = $results->fetch_array()){
$mycode[]=$row['zip'];
}
array_pop($mycode);
$mycode = implode(', ',$mycode);
//print_r ($mycode);
echo '<br /><br /><br />';
$usr="SELECT * FROM reg_temp WHERE zip IN('".join("','", $mycode)."')";
$results = $asies->query($usr);
while ($row = $results-> fetch_arra())
{
$name = $row['name'];
echo $name;
}
?>