Using the PHP Anthology MySQL.php class, I'm wondering can you loop through a row fetch statement within another one? I know I could use a LEFT JOIN probably, but i'll end up with duplicate data in the array before displaying it. Something like this...My first $sql should grab a product number a person is linked to...basically an array of just product id's:
It doesn't give me attributes for the 2nd, 3rd etc products...like it's stopping at the first product. Should I be able to do this? I'm new to OOP...PHP Code:$sql = "
SELECT product_id
FROM table1
WHERE ....
";
$result = $db->query($sql);
echo "<ul>";
while ($row = $result->fetch())
{
echo $row['product_id'];
$sql2 =
"SELECT product_name, product_size, product_color
FROM ....";
$result2 = $db->query($sql2);
while ($row2 = $result2->fetch())
{
echo "<li>" . $row['product_name'] . "(Size:" . $row['product_size'] . " | Color: " . $row['product_color'] . ")<br>";
}
}






Bookmarks