Location: PHPKode > projects > BaseballNuke > baseballNuke-2.0/blocks/block-LastGame.php
<?php
/*
This file is part of baseballNuke.
Created by Shawn Grimes http://claimid.com/shawn

baseballNuke is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

baseballNuke is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with baseballNuke; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

if (eregi("block-Name_of_Block.php", $PHP_SELF)) {
  Header("Location: index.php");
  die();
}

global $prefix,$dbi,$module_name;

$sqlString= "SELECT defaultTeam FROM ".$prefix."_baseballNuke_settings  WHERE ID=1";
$resultDefaults=sql_query($sqlString,$dbi);
list($defaultTeam)=sql_fetch_row($resultDefaults,$dbi);


$sqlString="SELECT ".$prefix."_baseballNuke_schedule.gameID, DATE_FORMAT(gameDate,'%c-%d-%Y') Gdate, "
  ." TIME_FORMAT(gameTime, '%h:%i') Gtime, homeTeam, visitingTeam, field, hruns, vruns "
  ." FROM ".$prefix."_baseballNuke_schedule, ".$prefix."_baseballNuke_boxscores WHERE "
  .$prefix."_baseballNuke_schedule.gameID=".$prefix."_baseballNuke_boxscores.gameID AND gameDate <= CURDATE() AND gameTime <= CURTIME() "
  ." AND (hruns>0 OR vruns>0) ORDER BY gameDate DESC, gameTime DESC LIMIT 1";


//$content.="<B>$sqlString</B><BR><BR>";

$resultNextGame=sql_query($sqlString,$dbi);
if (sql_num_rows($resultNextGame,$dbi) > 0) {
  list($gameID, $Gdate, $Gtime, $homeTeam, $visitingTeam, $field, $hruns, $vruns)=sql_fetch_row($resultNextGame, $dbi);
  $content.="<strong>Last Game Resulst</strong><BR>";
  $content.="<a href=modules.php?name=baseballNuke&amp;page=gameResults&view=".$gameID.">$Gdate at $Gtime</a><BR>";
  if ($defaultTeam == $homeTeam){
    $content.="$visitingTeam ($vruns)<BR>";
    $content.="<b>$homeTeam ($hruns)</b><BR>";
  }else{
    $content.="<b>$visitingTeam ($vruns)</b><BR>";
    $content.="$homeTeam ($hruns)<BR>";
  }
}
else{
  $content.="There are no upcoming games.";
 }




?>
Return current item: BaseballNuke