First of all I see two problems with your code,
problem 1:
since you are looping through all your records using,
while ($row = mysql_fetch_assoc($result_stats))
{
why do you need the,
while($i < $statcount)
{
for ?
Problem 2:
This is what cause to empty all the data except the first record.
unset($result_stats);
this should happen after existing the while loops. otherwise as soon as you write the first record you are unseting the variable so for next round that $result_stats array will be empty so it prints the empty values.
try this,
<?php
$i=0;
while ($row = mysql_fetch_assoc($result_stats))
{
$tbgcolor = is_int($i / 2)?"#efefef":"#ffffff";
$pid = mysql_result($result_stats,0,"players.id");
$goals = mysql_result($result_stats,0,"player_stats.goals");
$assists = mysql_result($result_stats,0,"player_stats.assists");
$minutes = mysql_result($result_stats,0,"player_stats.minutes");
$xtra1 = mysql_result($result_stats,0,"player_stats.xtra1");
$xtra2 = mysql_result($result_stats,0,"player_stats.xtra2");
$xtra3 = mysql_result($result_stats,0,"player_stats.xtra3");
$xtra4 = mysql_result($result_stats,0,"player_stats.xtra4");
$shotper = ROUND($goals / $xtra4 * 100, 2);
$xtra5 = mysql_result($result_stats,0,"player_stats.xtra5");
$position = mysql_result($result_stats,0,"players.position");
$fname = mysql_result($result_stats,0,"players.fname");
$lname = mysql_result($result_stats,0,"players.lname");
$stats .= "
<tr bgcolor=\"".$tbgcolor."\" align=\"center\">
<td class=\"table_text\">
$fname $lname ($position) </td>
<td class=\"table_text\">$goals</td>
<td class=\"table_text\">$assists</td>";
if($user_xtra1 == 1)
{
$stats .= "<td class=\"table_text\">$xtra1</td>";
}
if($user_xtra2 == 1)
{
$stats .= "<td class=\"table_text\">$xtra2</td>";
}
if($user_xtra3 == 1)
{
$stats .= "<td class=\"table_text\">$xtra3</td>";
}
if($user_xtra4 == 1)
{
$stats .= "<td class=\"table_text\">$xtra4</td>";
}
$stats .= "
<td class=\"table_text\">$minutes</td></tr>";
$i++;
}
unset($result_stats);
?>
Thanks,
Regards,
niroshan