We may find the above is a gotcha in that it is over complex, and overkill. Here is something simpler that should do the job: (This is scratch code, not tested.)
PHP Code:
<?php
// push all data into an array so you can release MySQL
$array = array();
// make sure to index it so you don't have keys tripping over each other
$table = <<< HDR
<table border="0" cellspacing="4" cellpadding="4" width="100%">
<tbody>
<tr>
<td><u><b>Date</b></u></td>
<td><u><b>Home Team</b></u></td>
<td><u><b>Home Score</b></u></td>
<td><u><b>Away Team</b></u></td>
<td><u><b>Away Score</b></u></td>
</tr>
HDR;
// now cycle through $array, extracting the seven datum in each row and generating appropriate HTML
$win = $loss = 0;
foreach($array as $key => $v) {
// record index = $key
$table .= "<tr>\n";
$table .= "<td>$v[0]</td>\n<td>$v[1]</td>\n<td>$v[2]</td>\n<td>$v[3]</td>\n<td>$v[4]</td>\n<td>$v[5]</td>\n<td>$v[6]</td>\n";
$table .= "</tr>\n";
$win .= ($v[4]>$v[6]) ? 1 : 0;
$loss .= ($v[4]<$v[6]) ? 1 : 0;
}
$table .= "</tbody>\n</table>\n";
$table = "<p>Record: " . $win . " - " . $loss . "</p>\n" . $table;
echo $table;
?>
As loops go, the above may be described as a self indexing end-of-file (EOF) loop. It doesn't need to be told how many records there are (though it will find out on its own). It just starts at the first row in $array and keeps going until it runs into what used to be called the 'first non-existent row', or EOF. Of course we need an array, and if you examine the above foreach() you'll see that the array is set up with an index (0,1,..,n) and a corresponding array within each row.
Eg.
PHP Code:
<?php
$array = array();
// cycle through database table to build each row
while(!$EOF) {
// MySQL retrieve $f1..$f7
$array[] = array($f1,$f2,$f3,$f4,$f5,$f6,$f7);
}
?>
If this is ahead of what you're being taught, don't use it. You'll get your wings clipped. Stay on par with the course material.