Location: PHPKode > projects > BaseballNuke > baseballNuke-2.0/blocks/block-TopPitchers.php
<?php
$TeamLeaders=3;
/*
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();
}


	$TEAM_NAME=$defaultTeam;

global $prefix, $multilingual, $currentlang, $dbi, $boxTitle, $content, $pollcomm, $user, $cookie, $userinfo;
	//echo "<h1>HERE</h1>";
	//echo "<tr><td>";
	OpenTable2();
for ($MyCounter=0; $MyCounter<=1; $MyCounter++)
{
  $content.="<table>";
  
  if ($MyCounter ==0){
    $content.="<tr bgcolor=$bgcolor2><th colspan=20>Team Leader In Least ERA</th></tr>";
  }else if ($MyCounter ==1) { 
    $content.="<tr bgcolor=$bgcolor2><th colspan=20>Team Leader In Most Strikeouts</th></tr>";
  }

  $content.="   <tr bgcolor=$bgcolor2>
               <td width=25><b><font color=$textcolor1>#</font></b></td>
               <td width=245><b><font color=$textcolor1>Pitching</font></b></td>
            ";

//PITCHING STATS
	
  if ($MyCounter ==0) {
    $content.="<td width=25><b><font color=$textcolor1>ERA</font></b></td></tr>";
    $sqlString="SELECT DISTINCT ".$prefix."_baseballNuke_players.playerID, lastname, firstname, middlename, jerseyNum, ".
		" round(sum((piER/piIP)*7),2) as ERA ".
		"FROM ".$prefix."_baseballNuke_stats, ".$prefix."_baseballNuke_players, ".$prefix."_baseballNuke_schedule".
		" WHERE ".$prefix."_baseballNuke_schedule.gameID=".$prefix."_baseballNuke_stats.gameID".
		" AND ".$prefix."_baseballNuke_players.season='".$_COOKIE["season"]."' ".
		" AND DATE_FORMAT(gameDate, \"%Y\")='".$_COOKIE["season"]."' ".
		" AND piIP>0 ".
		" AND ".$prefix."_baseballNuke_stats.playerID=".$prefix."_baseballNuke_players.playerID".
		" GROUP BY playerID ".
		" ORDER BY ERA ASC".
		" LIMIT ".$TeamLeaders;
    // echo "SQL: $sqlString<BR>";
     $resultPlayers=sql_query($sqlString, $dbi);
     //echo "CNT: " . sql_num_rows($resultPlayers, $dbi);
     for ($m=0; $m < sql_num_rows($resultPlayers, $dbi); $m++) {
       list($playerID,$lastname, $firstname, $middlename, $jerseyNum, $ERA)=sql_fetch_row($resultPlayers, $dbi);
       $content.="<tr>
			    <td><font size=2 color=#000000>".$jerseyNum."</td>
	    		    <td align=left><font size=2 color=#000000><a href=modules.php?name=".$module_name."&amp;page=playerStats&playerID=".$playerID.">".$lastname.", ".$firstname."</a></td>
		  	    <td><font size=2 color=#000000>$ERA</td>
			</tr>";
     }	
     $content.="</table>";
    
  }else if($MyCounter==1){
    $content.="               <td width=35><b><font color=$textcolor1>K</font></b></td></tr>";
    $sqlString="SELECT DISTINCT ".$prefix."_baseballNuke_players.playerID, lastname, firstname, middlename, jerseyNum, ".
		" sum(piSO) as piSO ".
		" FROM ".$prefix."_baseballNuke_stats, ".$prefix."_baseballNuke_players, ".$prefix."_baseballNuke_schedule".
		" WHERE ".$prefix."_baseballNuke_schedule.gameID=".$prefix."_baseballNuke_stats.gameID".
		" AND ".$prefix."_baseballNuke_players.season='".$_COOKIE["season"]."' ".
		" AND DATE_FORMAT(gameDate, \"%Y\")='".$_COOKIE["season"]."' ".
		" AND piIP>0 ".
		" AND ".$prefix."_baseballNuke_stats.playerID=".$prefix."_baseballNuke_players.playerID".
		" GROUP BY playerID ".
		" ORDER BY piSO DESC".
		" LIMIT ".$TeamLeaders;
    $resultPlayers=sql_query($sqlString, $dbi);
    for ($m=0; $m < sql_num_rows($resultPlayers, $dbi); $m++) {
      list($playerID,$lastname, $firstname, $middlename, $jerseyNum, $piSO)=sql_fetch_row($resultPlayers, $dbi);
      $content.="<tr>
			    <td><font size=2 color=#000000>".$jerseyNum."</td>
	    		    <td align=left><font size=2 color=#000000><a href=modules.php?name=".$module_name."&amp;page=playerStats&playerID=".$playerID.">".$lastname.", ".$firstname."</a></td>
		  	    <td><font size=2 color=#000000>$piSO</td>
			</tr>";
    }
	
    $content.="</table>";
  }
  
       
 }
CloseTable2();
// echo "</td></tr>";


?>

Return current item: BaseballNuke