So are you saying that
$sql = 'SELECT * FROM products WHERE id = '.$id;
is expected to return more than one row possibly??
If so, then you'll want to include a while loop when fetching your results:
foreach ($contents as $id=>$qty) {
$sql = 'SELECT * FROM products WHERE id = '.$id;
$result = $db->query($sql);
while ($row = $result->fetch()) {
extract($row);
echo $row['name'];
echo ' , ';
}
}
If I'm wrong in my assumptions, can you elaborate a bit more on the expected results and what's currently happening?