Average Draft Position

S h a r e :

Week: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17

[php]
$Week = $_REQUEST[“Week”];
if(empty($Week)) $Week = 17;

$query = “select concat(C.city,’ ‘,C.teamName,’ at ‘,B.city,’ ‘,B.teamName) as Game,
sum(if(gameID = gameID1,1,0)) + sum(if(gameID = gameID2,1,0)) + sum(if(gameID = gameID3,1,0)) as Count
from nfl_gamedata as A, nfl_team as B, nfl_team as C, challenges
where A.team = B.teamID
and A.opponent = C.teamID
and homeAway = ‘H’
and gameWeek = $Week
and week = $Week
group by gameID
having Count > 0
order by Count desc”;

$result = mysql_query($query);

echo “[h2]Most Popular Games, Week ” . $Week . “[/h2]”;
echo “[table class=\”data_table\” width=\”100%\” cellpadding=\”2\” cellspacing=\”2\” border=\”0\”]”;
echo “[tr class=\”data_row_hdr\”][th class=\”data_negative\”][div class=\”data_left\”]Game[/div][/th][th class=\”data_negative\”]Count[/th][/tr]”;
$count = 0;
while ( $row = mysql_fetch_array($result) )
{
$game = $row[‘Game’];
$timesUsed = $row[‘Count’];
$count = $count + 1;
echo “[tr][td class=\”data_odd\”][div class=\”data_left\”]$count. $game[/div][/td]”;
echo “[td class=\”data_odd\”]$timesUsed[/td][/tr]”;
}
echo “[/table]”;

$query = “select concat(position,’ ‘,left(firstName,1),’.’,lastName,’, ‘,rosters.team) as player, depth, homeAway, opponent as opp, round(avg((rosters.round*2)-2+rosters.pick),2) as adp, min((rosters.round*2)-2+rosters.pick) as high, max((rosters.round*2)-2+rosters.pick) as low, count(rosters.round) as timesDrafted
from nfl_player, nfl_gamedata, challenges, rosters
where playerID = player
and curTeam = nfl_gamedata.team
and challengeID = challenge
and GameWeek = $Week and week = $Week
group by player having timesDrafted > 3 order by adp asc limit 100”;

$result = mysql_query($query);

echo “[h2]Top Drafted Players, Week ” . $Week . “[/h2]”;
echo “[table class=\”data_table\” width=\”100%\” cellpadding=\”2\” cellspacing=\”2\” border=\”0\”]”;
echo “[tr class=\”data_row_hdr\”][th class=\”data_negative\”][div class=\”data_left\”]Player[/div][/th][th class=\”data_negative\”]Opp[/th][th class=\”data_negative\”]ADP[/th][th class=\”data_negative\”]H[/th][th class=\”data_negative\”]L[/th][th class=\”data_negative\”]#[/th][/tr]”;
$count = 0;
while ( $row = mysql_fetch_array($result) )
{
$player = $row[‘player’];
$depth = $row[‘depth’];
$homeAway = $row[‘homeAway’];
$opp = $row[‘opp’];
$adp = $row[‘adp’];
$high = $row[‘high’];
$low = $row[‘low’];
$timesDrafted = $row[‘timesDrafted’];
$count = $count + 1;
if($homeAway == “A”) $at = “@”; else $at = “”;
echo “[tr][td class=\”data_odd\”][div class=\”data_left\”]$count. $player[/div][/td]”;
echo “[td class=\”data_odd\”]$at$opp[/td]”;
echo “[td class=\”data_odd\”]$adp[/td]”;
echo “[td class=\”data_odd\”]$high[/td]”;
echo “[td class=\”data_odd\”]$low[/td]”;
echo “[td class=\”data_odd\”]$timesDrafted[/td][/tr]”;
}
echo “[/table]”;
echo “[span style=\”font-size: 0.85em;\”]H = earliest draft spot (high)[br /]L = latest draft spot (low)[br /]# = number of times drafted[/span]”;
[/php]