label = $label; //FILL TEAMS ARRAYS /**** not doing this thru database this year $result = mysql_query("select TeamKey,TeamName from tblTeams t,teamindex i where t.teamkey=i.teamid and i.year='2003' group by t.TeamName order by finish desc",$db); $i = -1; $j = mysql_num_rows($result); while ($myrow=mysql_fetch_array($result)) { $i++; $this->teams[$i][0]=$myrow["TeamKey"]; $this->teams[$i][1]=$myrow["TeamName"]; $j--; $this->teamsR[$j][0]=$myrow["TeamKey"]; $this->teamsR[$j][1]=$myrow["TeamName"]; } ****/ $this->teams = array ( array('6', 'Ron DMC'), array('40', 'Outside Your Mind'), array('37', 'Vampboozled'), array('8', 'Pathetic No Names'), array('32', 'Lando Calirissian\'s Charisma'), array('28', 'Road Runner'), array('2', 'Haha Raja'), array('39', 'Neuter Your Owners'), array('33', 'Lego My Bengal'), array('35', 'He\'s Already Picked'), array('4', 'Sweep the Leg Johnny'), ); for ($i=sizeof($this->teams)-1; $i>=0; $i--) { $this->teamsR[] = $this->teams[$i]; } //LENGTH OF ROUND AND DRAFT $this->picksPerRound = count($this->teams); $this->roundsPerDraft = 20; //WHOSE PICK IS IT? $sql = "select max(overall) as mx from tblDraft where label='$this->label'"; //echo $sql; $result = mysql_query($sql,$db) or die("BAD OVERALL CALC"); if (mysql_num_rows($result) > 0) $this->overall = mysql_result($result,0,"mx") + 1; else $this->overall = 1; $this->round = ceil($this->overall / $this->picksPerRound); $this->pick = $this->overall - (($this->round-1)*$this->picksPerRound); $this->double = ($this->round > 10) ? 1 : 0; $this->snake = 0; if (($this->double==0) && ($this->round % 2 == 0)) $this->snake = 1; if (($this->double==1) && (($this->round % 4 == 1) || ($this->round % 4 == 2))) $this->snake = 1; $this->onclock = $this->pick - 1; if ($this->snake==0) $this->teamID = $this->teams[$this->onclock][0]; else $this->teamID = $this->teamsR[$this->onclock][0]; if ($this->overall > $this->picksPerRound * $this->roundsPerDraft) $this->done = 1; else $this->done = 0; echo "\n\n\n\n"; } //constructor function hasBeenDrafted($playerID) { global $db; $sql = "select id from tblDraft where playerID=$playerID and label='$this->label'"; $result = mysql_query($sql,$db); return(mysql_num_rows($result)>0); } function draftPlayer($playerID) { global $db; mysql_query("insert into tblDraft (teamID, playerID, overall, label) values ('$this->teamID', '$playerID', '$this->overall', '$this->label');",$db); $resultP = mysql_query("select * from tblPlayers where id=$playerID",$db); if (mysql_num_rows($resultP)==0) echo "player not found. you might be out of players.
"; $resultT = mysql_query("select * from tblTeams where TeamKey=$this->teamID",$db); echo mysql_result($resultP,0,"first")." ".mysql_result($resultP,0,"last")." added to team ".mysql_result($resultT,0,"TeamName")."
\n"; $this->overall++; $this->pick++; if ($this->pick > $this->picksPerRound) { $this->pick = 1; $this->round++; } if ($this->round > $this->roundsPerDraft) $this->done = 1; $this->double = ($this->round > 10) ? 1 : 0; $this->snake = 0; if (($this->double==0) && ($this->round % 2 == 0)) $this->snake = 1; if (($this->double==1) && (($this->round % 4 == 1) || ($this->round % 4 == 2))) $this->snake = 1; $this->onclock = $this->pick - 1; if ($this->snake==0) $this->teamID = $this->teams[$this->onclock][0]; else $this->teamID = $this->teamsR[$this->onclock][0]; } function getTeam($teamID=-1, $pos="", $sep) { global $db; if ($teamID==-1) $teamID = $this->teamID; if ($teamID==NULL) return NULL; if (!$pos=="") $pos = " and p.pos='$pos'"; $result = mysql_query("select * from tblDraft d,tblTeams t,tblPlayers p where d.teamID=t.TeamKey and d.teamID=$teamID and d.playerID=p.id and d.label='$this->label'$pos order by overall"); //echo "teamID=" . $teamID . ""; // echo "select * from tblDraft d,tblTeams t,tblPlayers p where d.teamID=t.TeamKey and d.teamID=$teamID and d.playerID=p.id and d.label='$this->label'$pos order by overall"; $team = ""; $lim = mysql_num_rows($result); if ($lim>0) for ($i=0; $i<$lim; $i++) { $team = $team . mysql_result($result,$i,"first")." ".mysql_result($result,$i,"last"); if ($i<($lim-1)) $team = $team . $sep; } return $team; } function getOnClockTeam() { if ($this->snake == 0) return ($this->teams[$this->onclock][1]); else return ($this->teamsR[$this->onclock][1]); } function getNeeds() { global $db; $needs = "Needs: "; $pos = array ( array ('QB','3'), array ('RB','5'), array ('WR','6'), array ('PK','2'), array ('Def','2') ); for ($i=0; $iteamID and d.playerID=p.id and d.label='$this->label' and pos ='" . $pos[$i][0] . "' order by overall",$db); $lim = mysql_num_rows($result); $num = $pos[$i][1] - $lim; if ($num>0) { if ($needs!="Needs: ") $needs = $needs . ", "; $needs = $needs . $pos[$i][0] . "-" . $num; } } return $needs; } function getPlayers($pos) { } function getPlayersDropDown($sel, $left=0) { global $db; $o = " order by rank"; switch ($sel) { case "all" : $where = " $o"; break; case "qb" : $where = " where pos='QB' $o"; break; case "rb" : $where = " where pos='RB' $o"; break; case "wr" : $where = " where pos='WR' $o"; break; case "k" : $where = " where pos='PK' $o"; break; case "def" : $where = " where pos='Def' $o"; break; case "full" : $where = " order by last"; } $selStr = "\n"; return($selStr); } } ?>