I have this code that generates an array automatically with the data of a query:
$Codigos = array();
while($row = mysqli_fetch_array($RPedidos)) { $Codigos[] = $row['id']; }
$Idpedidos = implode(',', $Codigos);
I convert it to a value separated by ,
because then I make a query with FIND_IN_SET
. Now apart from that query I have to do another one with a loop to consult each of the codes that it generates separately.
and I'm not sure how to do it. I understand that I have an already created array that is called $ Codes but I do not know very well the syntax that it has since I can not do a print_r to show the data because I am generating a pdf and it does not let me do print_r.
To make a loop that goes through all the codes that I would have to use? the array $ Codes or the Implode separated by ,
?
I've tried it this way:
foreach($Codigos as $DContPedidos) {
$CInPedidos = mysqli_query($Conectar, 'SELECT * FROM Pedidos WHERE 'id' = '.$DContPedidos["id"].' ');
$html .= 'Codigo Pedidos: '.$CInPedidos["codpedido"].'<br/>';
}
but I get error Warning: Illegal string offset 'id' in
with what I understand that the fault I have in the query because $ ContEeds does not have a field called id.
If so, what data do I have to put in DContPedidos
to read the content?