"; // connect to database include 'dbc.php'; $font = ''; $fend = ''; $query = "SELECT SUM(GP) AS GP, SUM(W) AS W, SUM(L) AS L, SUM(T) AS T, SUM(GF) AS GF, SUM(GA) AS GA, CoachID FROM CoachStats WHERE Type = 'Regular' GROUP BY CoachID"; $result = mysql_query ($query, $connection); $NumCoaches = mysql_numrows($result); $i = -1; while ($row = mysql_fetch_array ($result)){ $i++; $CoachID = $row["CoachID"]; $coach_bio = "SELECT * FROM Coaches WHERE CoachID = $CoachID"; $nameres = mysql_fetch_array(mysql_query($coach_bio,$connection)); $CoachName[$i] = $nameres["FirstName"] . " " . $nameres["LastName"]; $CoachTeamNum = $nameres["Team"]; $team_query = "SELECT * FROM Teams WHERE TeamNum = $CoachTeamNum"; $team_result = mysql_fetch_array(mysql_query($team_query,$connection)); $City = $team_result["City"]; $Club = $team_result["Club"]; $CoachTeam[$i] = $City . " " . $Club; if ($CoachTeam[$i] == " "){ $CoachTeam[$i] = "Free Agent"; } $CoachGames[$i] = $row["GP"]; $CoachWins[$i] = $row["W"]; $CoachLosses[$i] = $row["L"]; $CoachTies[$i] = $row["T"]; $CoachGF[$i] = $row["GF"]; $CoachGA[$i] = $row["GA"]; $CareerPct = ((($CoachWins[$i]*2)+$CoachTies[$i])/($CoachGames[$i]*2)) * 1000; if ($CareerPct == 1000){ $CoachPct[$i] = 1000; } else { $CoachPct[$i] = number_format($CareerPct,0); } $CoachCheckPct[$i] = $CoachPct[$i]; $CoachCheckPct2[$i] = $CoachPct[$i]; } rsort($CoachCheckPct); for ($x = 0; $x < $NumCoaches; $x++) { for ($y = 0; $y < $NumCoaches; $y++) { if ($CoachCheckPct2[$y] == $CoachCheckPct[$x]) { $Loop[$x] = $y; $CoachCheckPct2[$y] = -10; $CoachCheckPct[$x] = -10; $y = $NumCoaches; } } } print "
All Coach Stats (by Pct)

"; print ''; for ($i = 0; $i < $NumCoaches; $i++){ $Rank = $i + 1; print ''; if ($CoachPct[$Loop[$i]] == 1000){ print ''; } print '
'.$font.'No.'.$fend.' '.$font.'Coach'.$fend.' '.$font.'Current Team'.$fend.' '.$font.'Games'.$fend.' '.$font.'W'.$fend.' '.$font.'L'.$fend.' '.$font.'T'.$fend.' '.$font.'GF'.$fend.' '.$font.'GA'.$fend.' '.$font.'Pct'.$fend.'
'.$font.$Rank.$fend.'. '.$font.$CoachName[$Loop[$i]].$fend.' '.$font.$CoachTeam[$Loop[$i]].$fend.' '.$font.$CoachGames[$Loop[$i]].$fend.' '.$font.$CoachWins[$Loop[$i]].$fend.' '.$font.$CoachLosses[$Loop[$i]].$fend.' '.$font.$CoachTies[$Loop[$i]].$fend.' '.$font.$CoachGF[$Loop[$i]].$fend.' '.$font.$CoachGA[$Loop[$i]].$fend.''.$font.'1.000'; } else { print ''.$font.'.'; printf ("%03d", $CoachPct[$Loop[$i]]); } print $fend.'
'; // print $NumCoaches; ?>