If I have this array:
$ids = [1, 34, 36];
How do I get data from a table from each of ID using this query:
$query = $DB->Prepare('SELECT name, address FROM tContacts WHERE id = ?');
I tried using:
foreach ($ids AS $val) {
$query = $DB->Prepare('SELECT name, address FROM tContacts WHERE id = ?');
$rs = $DB->Execute($query, array($val));
$i = 0;
foreach($rs as $rows)
{
$rs[$i++]=array(
'name' => $rows['name'],
'address' => $rows['address']
);
}
}
And when I tried to:
print_r($rs);
It only display the last row, not 3 rows as I intended.