Code: Select all
<?php
function GameScoreDisplay ($type, $team){ //$type could be "thisweek, nextweek, schedule, scores, teams
global $games, $type, $team, $dothis;
include_once ("TCode/GamesScores.php");
$games=find_GamesScores("hmspl", "09"); //array created in GamesScores.php
$seasonstart = mktime( 0, 0, 0, 5, 10, 2009 )/86400;
$seasonend = mktime( 0, 0, 0, 9, 10, 2009 )/86400;
$seasonend2 = date('Y-m-d', mktime(0, 0, 0, 9, 10, 2009));
$today = date('Y-m-d');
$now = mktime(0, 0, 0, date("m") , date("d"), date("Y"))/86400;
$num_games=sizeof ($games);
switch ($type){
case "thisweek":
$dothis = "$g[5]==$week";
$remainder= ((abs($now - $seasonstart)/7)- (floor(abs($now - $seasonstart)/7)));
if ($remainder ==0){
$week = abs($now - $seasonstart)/7+1;
}elseif ($remainder >0.7){
$week = floor(ceil(abs($now - $seasonstart)/7)+1.4);
}else {
$week = ceil(abs($now - $seasonstart)/7);
}
break;
case "nextweek":
$dothis = "$g[5]==$week";
$remainder= ((abs($now - $seasonstart)/7)- (floor(abs($now - $seasonstart)/7)));
if ($remainder ==0){
$week = abs($now - $seasonstart)/7+2;
}elseif ($remainder >0.7){
$week = floor(ceil(abs($now - $seasonstart)/7)+2.4);
}else {
$week = ceil(abs($now - $seasonstart)/7)+1;
}
break;
case "schedule":
$dothis = "1 == 1"; // this ok to do? Just want to enter loop
break;
case "scores":
$dothis = "1 == 1"; // this ok to do? Just want to enter loop
break;
case "teams":
if (isset($team)){
$dothis = "$g[3]==$team || $g[4]==$team";
}
break;
}
global $MonthNumInit==0;
echo "<div id=\"results\">";
echo "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
foreach($games as $g):
if ($dothis){
global $date = $g[1];
global $Weekday = date('D', strtotime($date));
global $MonthNum = date ('n', strtotime($date));
global $Dayofmonth = date ('d', strtotime($date));
global $Monthheader = date('F', strtotime ($date));
global $Location = $g[2];
global $Visitor = $g[3];
global $Home = $g[4];
global $Weeks = $g[5];
global $vis1=$g[6];
global $home1=$g[7];
global $vis2=$g[8];
global $home2=$g[9];
global $status1=$g[10];
global $status2=$g[11];
if ($Home == "OPN"){
switch ($type){
case "schedule":
function schedule("showOPN");
break;
case "nextweek":
function schedule("showOPN");// end of season message
break;
case "thisweek":
if ($date < $today){
//do nothing
break;
}else{
function schedule("showOPN"); //end of season message
}
break;
}
}else{
switch ($type){
case "schedule":
function schedule("showSCHEDULE");
break;
case "nextweek":
function schedule("showSCHEDULE");// end of season message
break;
case "thisweek":
function schedule("showSCORES");// needs "need scores", end of season message
break;
case "scores":
function schedule("showSCORES");
break;
}
} //end ($home == "OPN")
}
endforeach;
}
function schedule ($showthis){
if ($MonthNum != $MonthNumInit){
if($Monthheader == "May"){
echo "<tr><td colspan=\"6\" bgcolor=\"#ADD8E6\"> <strong>$Monthheader</strong></td></tr>";
}elseif ($Monthheader == "June") {
echo "<tr><td colspan=\"6\" bgcolor=\"#999933\"> <strong>$Monthheader</strong></td></tr>";
}elseif ($Monthheader == "July") {
echo "<tr><td colspan=\"6\" bgcolor=\"#FF9933\"> <strong>$Monthheader</strong></td></tr>";
}elseif ($Monthheader == "August") {
echo "<tr><td colspan=\"6\" bgcolor=\"#66CC99\"> <strong>$Monthheader</strong></td></tr>";
}elseif ($Monthheader == "September") {
echo "<tr><td colspan=\"6\" bgcolor=\"#CCCC66\"> <strong>$Monthheader</strong></td></tr>";
}
$MonthNumInit = $MonthNum;
}
echo "<tr><td width=\"35\" align=\"right\">$Weekday</td>";// Mon,Tue...format
if($Monthheader == "May"){
echo "<td width=\"20\" align=\"center\" bgcolor=\"#ADD8E6\"><strong>$Dayofmonth</strong></td>";
}elseif ($Monthheader == "June") {
echo "<td width=\"20\" align=\"center\" bgcolor=\"#999933\"><strong>$Dayofmonth</strong></td>";
}elseif ($Monthheader == "July") {
echo "<td width=\"20\" align=\"center\" bgcolor=\"#FF9933\"><strong>$Dayofmonth</strong></td>";
}elseif ($Monthheader == "August") {
echo "<td width=\"20\" align=\"center\" bgcolor=\"#66CC99\"><strong>$Dayofmonth</strong></td>";
}elseif ($Monthheader == "September") {
echo "<td width=\"20\" align=\"center\" bgcolor=\"#CCCC66\"><strong>$Dayofmonth</strong></td>";
}
echo "<td width=\"35\" align=\"center\">$Location</td>"; //COL, ANC, TP3 format
if ($showthis == "showOPN"){
echo "<td colspan=\"3\" align=\"center\" bgcolor=\"#66CCFF\">Open Date</td></tr>";
}else{
echo "<td width=\"35\" align=\"right\">$Visitor</td><td> @ </td>";
echo "<td width=\"35\" align=\"left\">$Home</td></tr>";
}
if ($showthis == "showSCORES"){
if (isset ($status1)){ //status1
if ($status1=="C"){ // for completed game-1 score
if ($vis1>$home1){ //vis1>home1
echo "<tr><td colspan=\"3\" align=\"right\">1)</td><td align=\"right\"><strong>$vis1</strong></td><td>@</td><td>$home1</td></tr>";
}elseif ($vis1<home1){ //vis1<home1
echo "<tr><td colspan=\"3\" align=\"right\">1)</td><td align=\"right\">$vis1</td><td>@</td><td><strong>$home1</strong></td></tr>";
} else {
echo "<tr><td colspan=\"3\" align=\"right\">1)</td><td align=\"right\">$vis1</td><td>@</td><td>$home1</td></tr>";
}
}elseif ($status1=="FV1"){
echo "<tr><td colspan=\"3\" align=\"right\">1)</td><td align=\"right\">(F)$vis1</td><td>@</td><td><strong>$home1</strong></td></tr>";
}elseif ($status1=="FH1"){
echo "<tr><td colspan=\"3\" align=\"right\">1)</td><td align=\"right\"><strong>$vis1</strong></td><td>@</td><td>$home1(F)</td></tr>";
}elseif ($status1=="R1"){
echo "<tr><td colspan=\"3\" align=\"right\">1)</td><td colspan=\"3\" align=\"center\"><strong>Rain-Out</strong></td></tr>";
}elseif ($status1=="CANC"){
echo "<tr><td colspan=\"3\" align=\"right\">1)</td><td colspan=\"3\" align=\"center\"><strong>Cancelled</strong></td></tr>";
}
}
if ($status2=="C"){ // for completed game-2 score
// game-2
if ($status2=="C"){ // for completed game-2 score $g[6]=vis2...$g[7]=home2
if ($home2>$vis2){
echo "<tr><td colspan=\"3\" align=\"right\">2)</td><td align=\"right\"><strong>$home2</strong></td><td>@</td><td>$vis2</td></tr>";
}elseif ($home2<$vis2){
echo "<tr><td colspan=\"3\" align=\"right\">2)</td><td align=\"right\">$home2</td><td>@</td><td><strong>$vis2</strong></td></tr>";
} else {
echo "<tr><td colspan=\"3\" align=\"right\">2)</td><td align=\"right\">$home2</td><td>@</td><td>$vis2</td></tr>";
}
}elseif ($status2=="FV2"){
echo "<tr><td colspan=\"3\" align=\"right\">2)</td><td align=\"right\"><strong>$home2</strong></td><td>@</td><td>$vis2(F)</td></tr>";
}elseif ($status2=="FH2"){
echo "<tr><td colspan=\"3\" align=\"right\">2)</td><td align=\"right\">(F)$home2</td><td>@</td><td><strong>$vis2</strong></td></tr>";
}elseif ($status2=="R2"){
echo "<tr><td colspan=\"3\" align=\"right\">2)</td><td colspan=\"3\" align=\"center\"><strong>Rain-Out</strong></td></tr>";
}elseif ($status2=="D2"){
echo "<tr><td colspan=\"3\" align=\"right\">2)</td><td colspan=\"3\" align=\"center\"><strong>Darkness</strong></td></tr>";
}elseif ($status2=="CANC"){
echo "<tr><td colspan=\"3\" align=\"right\">2)</td><td colspan=\"3\" align=\"center\"><strong>Cancelled</strong></td></tr>";
}
}
}//end ($showthis == "showSCORES")
}//end function schedule
?>