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
include("conect.php");
$colcod = $_POST['rubi'];
// $colcod = 'rubi';
include("config/conectar.php");
$colonias="SELECT zip FROM the_codes WHERE coloni LIKE '%$colcod%' ORDER BY coloni";
$resultados = $asies->query($colonias);
while ($fila = $resultados->fetch_array()){
$codigo[]=$fila['zip'];
}
array_pop($codigo);
$codigo = implode(', ',$codigo);
//print_r ($codigo); // <- Imprimimos para asegurarnos que todo está bien
$usuarios = "SELECT * FROM reg_temp WHERE zip IN ('".$codigo."') ";
$respuesta = $asies->query($usuarios);
while ($fila = $respuesta -> fetch_array()){
$nombre = $fila['name'];
echo $nombre;
}
?>