I need to query an MySQL table to get a list of names then, based off that list of names, query reports tied to it. Here is my code:
//query the peoples
$query_people = mysql_query("SELECT * FROM people ORDER BY people_name ASC")
while($fetch_people = mysql_fetch_array($query_people)){
$people_id = $fetch_people[people_id];
$people_name = $fetch_people[people_name];
$query_report = mysql_query("SELECT * FROM report WHERE report_entity = '$people_name'");
// output each person's name
echo($people_id.$people_name);
//get their reports
while($fetch_report = mysql_fetch_array($query_report)){
$report_id = $fetch_report[report_id];
$report_type = $fetch_report[report_type];
$report_narr = $fetch_report[report_narr];
echo($report_narr);
}
}
?>
When it outputs, I get this:
1Bill
2Bob "Bill's narrative"
3Tom "Bob's narrative"
4 "Tom's narrative"
Any thoughts on why it is skipping Bill's query on the nested loop?