Hi all,
I have been hammering on this one page for several days and am
frustrated to no end. I've finally got it where its pulling the stats
from the first person in the result set correctly, but there are three
problems that persist.
1- The name for the first player in the result set is not being
displayed. The row is there, but there's no player name.
2 - The stats illustrated for all players are those of that first
player (whose name is missing in problem #1).
3 - There are 15 "added" rows to the bottom of the table with no names
at all. As all names are accounted for in the displayed names and the
blank row in line #1, these are extras.
Could someone be so kind as to look over my code and point out to me
where I'm going wrong?
Here's the page in action:
Here's the code:
<?
$sql_players=mysql_query("select PLAYERS.player_number,
PLAYERS.last_name, PLAYERS.first_name from
PLAYERS where league_abbr='$league_abbr' and
level='$level' and team_name='$team'
and position!='G' and season='$season' order
by PLAYERS.last_name",$connection);
/ variables mentioned above are being passed in the URL of the page
/
$num_players=mysql_num_rows($sql_players);
$row=mysql_num_rows($sql_players);
while ($row = mysql_fetch_array($sql_players))
{
for ($q=0; $q<mysql_num_rows ($sql_players);
$q++)
//printf ("%s %s %s",$row[0], $row[1],
$row[2]);
do {
//-------------section for figuring stat totals-------------
$sql_goals=mysql_query("select count(*) as goals from SCORING where
team_abbr='$team_abbr' and goal_scorer='$row[player_number]' ");
$row0=mysql_fetch_array($sql_goals);
$goals=$row0[goals];
$sql_first_assists=mysql_query("select count(*) as first_assists from
SCORING where team_abbr='$team_abbr' and
assist_1st='$row[player_number]' ");
$row1=mysql_fetch_array($sql_first_assists);
$first_assists=$row1[first_assists];
$sql_second_assists=mysql_query("select count(*) as second_assists
from SCORING where team_abbr='$team_abbr' and
assist_2nd='$row[player_number]' ");
$row2=mysql_fetch_array($sql_second_assists);
$second_assists=$row2[second_assists];
$total_assists=$first_assists+$second_assists;
$points=$goals+$first_assists+$second_assists;
$sql_penalties=mysql_query("select count(*) as penalties from
PENALTIES where team_abbr='$team_abbr' and
player_number='$row[player_number]'");
$row3=mysql_fetch_array($sql_penalties);
$penalties=$row3[penalties];
$sql_penalties_time=mysql_query("select sum(pen_length) as
penalties_time from PENALTIES where team_abbr='$team_abbr' and
player_number='$row[player_number]'");
$row4=mysql_fetch_array($sql_penalties_time);
$penalties_time=substr("$row4[penalties_time]",0,-2);
//-------------end section for figuring stat totals-------------
printf("<table><tr align=left><td width=40>%s</td><td align=middle
width=15> </TD><td align=left width=150>%s,
%s</TD>",$myrow[player_number],$myrow[last_name],$myrow[first_name]);
echo "<td align=middle width=15> </td><td align=middle
width=40>$goals[0]</td><td align=middle width=15> </TD><td
align=middle width=50>$total_assists</td><td align=middle
width=15> </TD><td align=middle width=40>$points</td><td
align=middle width=15> </TD><td align=middle
width=40>$penalties</td><td align=middle width=15> </TD><td
align=middle width=40>$penalties_time:00</td></tr></table>";
} while ($myrow = mysql_fetch_array($sql_players));
}
?>
</td>
</tr>
</table>