include('header.php');
$divisions = mysql_query("SELECT divisions.name as divisionName,teams.logo,teams.name,users.nickname,teams.id as teamid FROM users_teams INNER JOIN teams ON (teams.id=users_teams.team) INNER JOIN users ON (users.id=users_teams.user) INNER JOIN divisions ON (divisions.id=users_teams.division) ORDER BY divisions.name,users_teams.points desc,teams.name;");
echo "
Conference I";
?>
$prevDiv = "";
while ($row = mysql_fetch_assoc($divisions))
{
if ($prevDiv != $row['divisionName'])
{
//if this is not the first time through loop
if ($prevDiv != "")
echo " |
";
if ($row['divisionName'] == "C")
echo " Conference II
";
echo "Division: ".$row['divisionName']." |
MP |
W |
D |
L |
GF |
GA |
Pts |
";
$prevDiv = $row['divisionName'];
}
$teamid = $row['teamid'];
$gameResults = mysql_query("select count(*),'Wins' as type from game where playoff=0 AND ((playerHome=$teamid AND scoreHome>ScoreAway) OR (playerAway=$teamid AND scoreAway>scoreHome)) UNION select count(*), 'Ties' as type from game where playoff=0 AND ((playerHome=$teamid OR playerAway=$teamid) AND scoreHome=scoreAway) UNION select count(*), 'Loss' as type from game where playoff=0 and ((playerHome=$teamid AND scoreHome";
mysql_query("UPDATE users_teams SET points=$pts WHERE team=$teamid;") or die (mysql_error());
}
$goalsScored = mysql_query("select sum(scoreHome) as gf, sum(scoreAway) as ga from game where playerHome=$teamid union select sum(scoreAway) as gf, sum(scoreHome) as ga from game where playerAway=$teamid;");
$goalsFor = 0;
$goalsAgainst = 0;
while($res = mysql_fetch_assoc($goalsScored))
{
$goalsFor += $res['gf'];
$goalsAgainst += $res['ga'];
}
echo "
 |
".$row['name']." - (".$row['nickname'].") |
$played |
".$teamResults['Wins']." |
".$teamResults['Ties']." |
".$teamResults['Loss']." |
$goalsFor |
$goalsAgainst |
$pts | ";
}
echo "
";
mysql_free_result($divisions);
echo "Overall Standings* = Playoff Team ";
$standings = mysql_query("SELECT teams.name,users.nickname,teams.id,points,users_teams.inPlayoffs FROM users_teams inner join teams on (teams.id=users_teams.team) INNER JOIN users on (users.id=users_teams.user) order by users_teams.points desc,teams.name;");
echo "
Rank | Team | Points | ";
$i = 1;
$prev = "";
while ($row = mysql_fetch_assoc($standings))
{
if ($i%2==0)
$bg = "bgcolor='#dddddd'";
else
$bg = "";
if ($row['points'] != $prev)
$rank = $i;
else
$rank = " ";
$prev = $row['points'];
$name = $row['name'];
if ($row['inPlayoffs'] == '1')
$name = "*".$row['name']."";
echo "$rank | $name (".$row['nickname'].") | ".$row['points']." | ";
$i++;
}
echo " ";
?>
include('footer.php');
?>
|