"; set_time_limit(0); function text_number($n) { // Array holding the teen numbers. If the last 2 numbers of $n are in this array, then we'll add 'th' to the end of $n $teen_array = array(11, 12, 13, 14, 15, 16, 17, 18, 19); // Array holding all the single digit numbers. If the last number of $n, or if $n itself, is a key in this array, then we'll add that key's value to the end of $n $single_array = array(1 => 'st', 2 => 'nd', 3 => 'rd', 4 => 'th', 5 => 'th', 6 => 'th', 7 => 'th', 8 => 'th', 9 => 'th', 0 => 'th'); // Store the last 2 digits of $n in order to check if it's a teen number. $if_teen = substr($n, -2, 2); // Store the last digit of $n in order to check if it's a teen number. If $n is a single digit, $single will simply equal $n. $single = substr($n, -1, 1); // If $if_teen is in array $teen_array, store $n with 'th' concantenated onto the end of it into $new_n if ( in_array($if_teen, $teen_array) ) { $new_n = $n . 'th'; } // $n is not a teen, so concant the appropriate value of it's $single_array key onto the end of $n and save it into $new_n elseif ( $single_array[$single] ) { $new_n = $n . $single_array[$single]; } // Return new return $new_n; } function beat($n) { switch ($n){ case 1: return 'narrowly beat'; break; case 2: return 'beat'; break; case 3: return 'toppled'; break; case 4: return 'pummelled'; break; case 5: return 'destroyed'; break; case 6: return 'out-gunned'; break; case 7: return 'out-played'; break; case 8: return 'bombed'; break; default: return 'completely destroyed'; } } function Position($n) { switch ($n){ case 'D': return 'Defenseman'; break; case 'G': return 'Goaltender'; break; default: return 'Forward'; } } $game_n = "SELECT * FROM Schedule WHERE Complete = 'Yes' AND Season = $SeasonNumber AND GameType = '$SeasonType' AND Level = 1 ORDER BY GameDay DESC LIMIT 1"; $gn = mysql_fetch_array(mysql_query($game_n,$connection)); // $show = "SELECT * FROM TJHLPageDisplay"; // $sr = mysql_fetch_array(mysql_query($show,$connection)); $show2 = "SELECT * FROM LeagueData WHERE League = 'TJHL'"; $lb = mysql_fetch_array(mysql_query($show2,$connection)); $ArtApp = $sr["ArtApp"]; // 1 = show, 0 = don't show $vw = " $AwayGoals){ $GWCheck = $AwayGoals + 1; $GWTeam = $HomeClub; $GWTeamNum = $HomeNum; $GWWholeName = $HomeTeam; $query = "SELECT * FROM GameDetailsScoring WHERE Season = $SeasonNumber AND Level = 1 AND Type = '$SeasonType' AND GameNum = $GameNum AND ScoreTeam = '$GWTeam'"; $Diff = $HomeGoals - $AwayGoals; } else if ($HomeGoals < $AwayGoals){ $GWCheck = $HomeGoals + 1; $GWTeam = $AwayClub; $GWTeamNum = $AwayNum; $GWWholeName = $AwayTeam; $query = "SELECT * FROM GameDetailsScoring WHERE Season = $SeasonNumber AND Level = 1 AND Type = '$SeasonType' AND GameNum = $GameNum AND ScoreTeam = '$GWTeam'"; $Diff = $AwayGoals - $HomeGoals; } else { $TieGame = TRUE; $query = "SELECT * FROM GameDetailsScoring WHERE Season = $SeasonNumber AND Level = 1 AND Type = '$SeasonType' AND GameNum = $GameNum ORDER BY Period DESC, ScoreTime DESC LIMIT 1"; } $result = mysql_query ($query, $connection); if ($TieGame == TRUE){ while ($row = mysql_fetch_array ($result)){ $GTPeriod = $row["Period"]; $GTTime = $row["ScoreTime"]; $GTScorer = $row["Goal"]; // print $GTPeriod . ' ' . $GTTime . ' ' . $GTScorer; } } else { $count = 1; while ($row = mysql_fetch_array ($result)){ if ($GWCheck == $count){ $GWPeriod = $row["Period"]; $GWTime = $row["ScoreTime"]; $GWScorer = $row["Goal"]; // print $GWTeam . ' ' . $GWPeriod . ' ' . $GWTime . ' ' . $GWScorer; } $count++; } } if ($TieGame == TRUE){ $GameStory .= $GTScorer . ' scored the game tying goal ' . $GTTime . ' '; $GameStory .= 'into the ' . text_number($GTPeriod) . ' period '; } else { $query = "SELECT * FROM Players WHERE Level = 1 AND Team = $GWTeamNum AND LastName = '$GWScorer' LIMIT 1"; $result = mysql_query ($query, $connection); while ($row = mysql_fetch_array ($result)){ $GWPosition = $row["Position"]; $PlayerScorer = $row["FirstName"] . ' ' . $row["LastName"]; $ScorerSummary = 'In ' . $HomeCity . ', ' . $GWWholeName . ' ' . Position($GWPosition) . ' ' . $PlayerScorer; } $GameStory .= $ScorerSummary . ' scored the game winner '; if ($GWPeriod > 3){ $OTG = $GWPeriod - 3; if ($SeasonType == 'PlayOff'){ $GameStory .= $GWTime . ' into the ' . text_number($OTG) . ' overtime period '; } else { $GameStory .= $GWTime . ' in overtime '; } } else { } if ($GWTeam == $HomeClub){ $GameStory .= 'as the ' . $HomeTeam . ' ' . beat($Diff) .' the ' . $AwayTeam . ' by a score of ' . $HomeGoals . '-' . $AwayGoals . '. '; } else { $GameStory .= 'as the ' . $AwayTeam . ' ' . beat($Diff) .' the ' . $HomeTeam . ' by a score of ' . $AwayGoals . '-' . $HomeGoals . '. '; } } if ($HomeGoals > $AwayGoals){ $query = "SELECT * FROM PlayerGameStats WHERE Season = $SeasonNumber AND Level = 1 AND Type = '$SeasonType' AND GameNum = $GameNum AND Team = $HomeNum AND Pts > 0 ORDER BY Pts DESC, G DESC LIMIT 1"; $StarScorerClub = $HomeClub; } else if ($HomeGoals < $AwayGoals){ $query = "SELECT * FROM PlayerGameStats WHERE Season = $SeasonNumber AND Level = 1 AND Type = '$SeasonType' AND GameNum = $GameNum AND Team = $AwayNum AND Pts > 0 ORDER BY Pts DESC, G DESC LIMIT 1"; $StarScorerClub = $AwayClub; } $result = mysql_query ($query, $connection); while ($row = mysql_fetch_array ($result)){ $PID = $row["PlayerID"]; $ScorerG = $row["G"]; $ScorerA = $row["A"]; $goalcheck = 0; $PositionScorer = "t "; $query22 = "SELECT * FROM Players WHERE PlayerID = $PID LIMIT 1"; $resultName = mysql_fetch_array(mysql_query($query22, $connection)); // print $resultName["Position"]; // $PostionScorer = $resultName["Position"]; $FullName = $resultName["FirstName"] . ' ' . $resultName["LastName"]; $GameStory .= $StarScorerClub . ' ' . Position($resultName["Position"]) . ' ' . $FullName . ' was the offensive star on the night as he recorded'; switch($ScorerG){ case 0: break; case 1: $GameStory .= ' 1 goal'; $goalcheck++; break; case 3: $GameStory .= ' a hat trick'; $goalcheck++; break; default: $GameStory .= ' ' . $ScorerG . ' goals'; $goalcheck++; break; } switch($ScorerA){ case 0: break; case 1: if ($goalcheck > 0){ $GameStory .= ' and'; } $GameStory .= ' 1 assist'; break; default: if ($goalcheck > 0){ $GameStory .= ' and'; } $GameStory .= ' ' . $ScorerA . ' assists'; break; } $GameStory .= '.

'; // print $ft . $FullName . ' ' . $row["G"] . 'g - ' . $row["A"] . 'a - ' .$row["Pts"] . 'pts
'; } } } print "
All Games Summary

"; print "
"; print $ft.$GameStory.'
'; ?>