PHP the SELECT FROM WHERE col IN no working using array

Posted by Sam Ram San on Stack Overflow See other posts from Stack Overflow or by Sam Ram San
Published on 2012-07-08T21:13:13Z Indexed on 2012/07/08 21:15 UTC
Read the original article Hit count: 137

Filed under:

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;
}
?>

© Stack Overflow or respective owner

Related posts about mysql