This script i have works good only thing i'm having trouble with is finding a way to move the column color around when viewing certain categories
ie- wins should have all rows in wins highlighted.
instead its the very first column of stats
heres the link to website www.theufhl.com/statistics/milestones/1
here is the code and i have highlighted the column color in red
<?php
function milestones($league) {
include("config.php");
//IF NO SEASON VARIABLE IS PASSED, SET THE OPEN SEASON, OR GET FIRST SEASON IF NONE OPEN
if(!$sid) {
$sql_seasons_statement = "SELECT * FROM seasons WHERE status = '1'";
$result_seasons = mysql_query("$sql_seasons_statement");
$total_seasons = mysql_num_rows($result_seasons);
if ($total_seasons > 0)
{
$open_season = mysql_result($result_seasons,0,"id");
}
else
{
$sql_seasonsp_statement = "SELECT * FROM seasons WHERE status != '1'";
$result_seasonsp = mysql_query("$sql_seasonsp_statement");
$total_seasonsp = mysql_num_rows($result_seasonsp);
if ($total_seasonsp > 0)
{
$open_season = mysql_result($result_seasonsp,0,"id");
}
else
echo "No Seasons Available Yet";
}
} else {
$sql_seasons_statement = "SELECT * FROM seasons WHERE id = '$sid'";
$result_seasons = mysql_query("$sql_seasons_statement");
$total_seasons = mysql_num_rows($result_seasons);
$open_season = mysql_result($result_seasons,0,"id");
$open_season_name = mysql_result($result_seasons,0,"name");
}
$seasons_query = mysql_query("SELECT id FROM seasons WHERE type = 1");
$where_statement = "";
$c = 0;
while($s = mysql_fetch_assoc($seasons_query)){
$where_statement .= "seasonid = " . $s['id']. " ";
if($c != mysql_num_rows($seasons_query) - 1){
$where_statement .= "OR ";
}
$c++;
}
// GOALIE STATS LOOKUP
$stats2 = "SELECT SUM(IF((schedule_scores.team1_score > schedule_scores.team2_score AND schedule_scores.team1 = teams.id) OR (schedule_scores.team1_score < schedule_scores.team2_score AND schedule_scores.team2 = teams.id),1,0)) AS w,
SUM(IF((schedule_scores.team1_score < schedule_scores.team2_score AND schedule_scores.team1 = teams.id) OR (schedule_scores.team1_score > schedule_scores.team2_score AND schedule_scores.team2 = teams.id),IF(schedule_scores.ot_game,0,1),0)) AS l,
SUM(IF((schedule_scores.team1_score < schedule_scores.team2_score AND schedule_scores.team1 = teams.id) OR (schedule_scores.team1_score > schedule_scores.team2_score AND schedule_scores.team2 = teams.id),IF(schedule_scores.ot_game,1,0),0)) AS otl,
player_stats.playerid as playerids,
SUM(player_stats.goals) as goals,
SUM(gminutes) as mp,
SUM(IF(goalsa>0,0,1)) as so,
COUNT(goals) as gp
FROM player_stats,teams,players,schedule_scores WHERE teams.id = player_stats.team_id AND players.id = player_stats.playerid AND players.position = 'G' AND schedule_scores.id = player_stats.game_id AND players.registered != '2' AND player_stats.leagueid = $league AND ($where_statement) GROUP BY player_stats.playerid";
$stats3 = mysql_query("$stats2");
$mstone_breakers1 = array(50, 100, 150, 200, 250, 300, 350, 400, 450);
$mstone_breakers2 = array(1000, 2000, 3000, 4000, 5000, 10000, 20000, 30000, 40000, 50000);
$mstone_breakers3 = array(10, 20, 30, 40, 50, 75, 100, 150, 200, 250);
// PLAYER STATS LOOKUP
$stats1 = "SELECT player_stats.playerid as playerid, SUM(player_stats.goals) as goals, SUM(player_stats.assists) as assists, SUM(goals+assists) as points, SUM(player_stats.played) AS num_played FROM player_stats, players WHERE players.id = player_stats.playerid AND players.registered != '2' AND player_stats.leagueid = $league AND ($where_statement) GROUP BY player_stats.playerid";
$stats = mysql_query("$stats1");
$mstone_breakers = array(50, 100, 150, 200, 250, 300, 350, 400, 450);
//Get milestones FOR goalie and players
while($stat4 = mysql_fetch_array($stats3)) {
foreach( $mstone_breakers1 as $i) {
if($stat4['w'] <= $i && $stat4['w'] > $i - 10) {
$w_milestones_temp_array[] = array($stat4['playerids'], $stat4['w'], $stat4['mp'], $stat4['so'], $stat4['gp'], $i);
}
if($stat4['gp'] <= $i && $stat4['gp'] > $i - 10) {
$gp_milestones_temp_array[] = array($stat4['playerids'], $stat4['w'], $stat4['mp'], $stat4['so'], $stat4['gp'], $i);
}
}
foreach( $mstone_breakers2 as $i) {
if($stat4['mp'] <= $i && $stat4['mp'] > $i - 400) {
$mp_milestones_temp_array[] = array($stat4['playerids'], $stat4['w'], $stat4['mp'], $stat4['so'], $stat4['gp'], $i);
}
}
foreach( $mstone_breakers3 as $i) {
if($stat4['so'] <= $i && $stat4['so'] > $i - 5) {
$so_milestones_temp_array[] = array($stat4['playerids'], $stat4['w'], $stat4['mp'], $stat4['so'], $stat4['gp'], $i);
}
}
}
while($stat = mysql_fetch_array($stats)) {
foreach( $mstone_breakers as $i) {
if($stat['goals'] <= $i && $stat['goals'] > $i - 10) {
$goals_milestones_temp_array[] = array($stat['playerid'], $stat['goals'], $stat['points'], $stat['assists'], $stat['num_played'], $i);
}
if($stat['points'] <= $i && $stat['points'] > $i - 10) {
$points_milestones_temp_array[] = array($stat['playerid'], $stat['goals'], $stat['points'], $stat['assists'], $stat['num_played'], $i);
}
if($stat['assists'] <= $i && $stat['assists'] > $i - 10) {
$assists_milestones_temp_array[] = array($stat['playerid'], $stat['goals'], $stat['points'], $stat['assists'], $stat['num_played'], $i);
}
if($stat['num_played'] <= $i && $stat['num_played'] > $i - 10) {
$played_milestones_temp_array[] = array($stat['playerid'], $stat['goals'], $stat['points'], $stat['assists'], $stat['num_played'], $i);
}
}
}
// Sort them
uasort($w_milestones_temp_array, 'w_sort');
uasort($gp_milestones_temp_array, 'gp_sort');
uasort($mp_milestones_temp_array, 'mp_sort');
uasort($so_milestones_temp_array, 'so_sort');
uasort($goals_milestones_temp_array, 'goals_sort');
uasort($points_milestones_temp_array, 'point_sort');
uasort($assists_milestones_temp_array, 'assist_sort');
uasort($played_milestones_temp_array, 'played_sort');
// Make them displayable
$position = 1;
foreach($w_milestones_temp_array as $i) {
$player = mysql_fetch_assoc(mysql_query("SELECT fname, lname, teamid FROM players WHERE id = " . $i[0]));
$team = mysql_fetch_assoc(mysql_query("SELECT name FROM teams WHERE id = " . $player['teamid']));
$w_milestones_array[] = array($position, ($i[1] == $i[5] ? "* - " : "") . $player['fname'] . " " . $player['lname'], $team['name'], $i[1], $i[2], $i[3], $i[4], $i[5] . " Wins");
$position ++;
}
$position = 1;
foreach($mp_milestones_temp_array as $i) {
$player = mysql_fetch_assoc(mysql_query("SELECT fname, lname, teamid FROM players WHERE id = " . $i[0]));
$team = mysql_fetch_assoc(mysql_query("SELECT name FROM teams WHERE id = " . $player['teamid']));
$mp_milestones_array[] = array($position, ($i[1] == $i[5] ? "* - " : "") . $player['fname'] . " " . $player['lname'], $team['name'], $i[1], $i[2], $i[3], $i[4], $i[5] . " Mins Played");
$position ++;
}
$position = 1;
foreach($so_milestones_temp_array as $i) {
$player = mysql_fetch_assoc(mysql_query("SELECT fname, lname, teamid FROM players WHERE id = " . $i[0]));
$team = mysql_fetch_assoc(mysql_query("SELECT name FROM teams WHERE id = " . $player['teamid']));
$so_milestones_array[] = array($position, ($i[1] == $i[2] ? "* - " : "") . $player['fname'] . " " . $player['lname'], $team['name'], $i[1], $i[2], $i[3], $i[4], $i[5] . " Shutouts");
$position ++;
}
$position = 1;
foreach($gp_milestones_temp_array as $i) {
$player = mysql_fetch_assoc(mysql_query("SELECT fname, lname, teamid FROM players WHERE id = " . $i[0]));
$team = mysql_fetch_assoc(mysql_query("SELECT name FROM teams WHERE id = " . $player['teamid']));
$gp_milestones_array[] = array($position, ($i[2] == $i[5] ? "* - " : "") . $player['fname'] . " " . $player['lname'], $team['name'], $i[1], $i[2], $i[3], $i[4], $i[5] . " Played");
$position ++;
}