Right now I have this page where I use foreach
to fill the page. I then have foreach
inside of that to get another table with rows on the specific ID. The problem being anything under the nested foreach doesn't fill.
Table
Example:
<!-- Get The Person. Results in ONE person. -->
<?
$list = $db2->prepare(" SELECT * FROM Table WHERE ID = ? ");
$list->execute(array($id));
$data = $list->fetchAll();
foreach ($data as $row) :?>
<div><?=$row["name"]?></div>
<!-- Get The Colors. Gets as many results as there are for that ID. -->
<?
$list2 = $db2->prepare(" SELECT * FROM AnotherTable WHERE ID = ? ");
$list2->execute(array($id));
$data2 = $list2->fetchAll();
foreach ($data2 as $row2) :?>
<div><?=$row2["color"]?></div>
<?endforeach?>
<!-- Doesn't show up on the page. -->
<div><?=$row["food"]?></div>
<?endforeach?>