Here's what I'm doing:
First, I'm printing all the records in a mysql table with a loop like this one (obviously I connect to the database first, but there's no need to show that):
Now, within this loop, I need to print another list from a different MySQL table, based on one of the fields that is coming from that first loop (like $data[matchid]). In essence, I need to preform a loop within a loop.
Yes, I have tried this, by basically simply taking the code above and pasting it within it (like where I have that echo line), but all that happens only ONE record from the original loop is displayed (however, the "secondary" loop does print it's records) I'm assuming there's some limit, or some restriction, or SOMETHING holding me back from being able to do this. Is it not possible with PHP? Or is there some solution I'm overlooking/don't know about?
First, I'm printing all the records in a mysql table with a loop like this one (obviously I connect to the database first, but there's no need to show that):
PHP:
$result = mysql_query("SELECT * FROM tablename ORDER BY id DESC",$db);
if ($data = mysql_fetch_array($result)) {
do {
echo "$data[id] - $data[name] ($data[matchid])";
} while ($data = mysql_fetch_array($result));
} else {
// No records.
echo "No records were found in the database.";
}
Now, within this loop, I need to print another list from a different MySQL table, based on one of the fields that is coming from that first loop (like $data[matchid]). In essence, I need to preform a loop within a loop.
Yes, I have tried this, by basically simply taking the code above and pasting it within it (like where I have that echo line), but all that happens only ONE record from the original loop is displayed (however, the "secondary" loop does print it's records) I'm assuming there's some limit, or some restriction, or SOMETHING holding me back from being able to do this. Is it not possible with PHP? Or is there some solution I'm overlooking/don't know about?