$aRow = array();
$query = "SELECT id, name FROM myTable";
while ($row = mysqli_fetch_assoc($db, $query)) {
$aRow[] = $row;
}
Now that I have several records in $aRow[], I'd like to iterate the $aRow[id] like this:
foreach ($aRow as $thisRow) {
$anID = $thisRow[id];
$query = "SELECT amount FROM mySubTable WHERE myTableID = {$anID}";
.
.
.
}
That doesn't seem to work - $anID doesn't have the expected value. How do I address the associative PHP array?
ETA: To more finely filter my question, after the WHILE completes, I have an array of DB records in $aRow[] that correspond to the database. Maybe I have: $aRow[1, 'Sally'], $aRow[2, 'Dick'], and $aRow[3, 'Jane'].
How to I assign a new variable to 'Dick'? $myVar = $aRow[?] such that $myVar will equal 'Dick'?