I have this code which i will post which gathers player info and stats from the database for records for entire season.
Someone helped me with the coding and I am trying to get the leaders for say most goals in season by a player and list the top 5 from the database
in this code i see hes taking the info from the tables
players, teams, player_stats,schedule_scores
so i have a seasons table which has id, name and status
I also see seasons in the schedule_scores and player_stats
how should i be trying to work this in so that i get the top 5 leaders for goals from any of the seasons that have been played
$stats_sql = " SELECT players.fname,
players.lname,
players.position,
teams.id as tid,
teams.name as team,
teams.division as divid,
player_stats.playerid as pid,
SUM(player_stats.goals) as goals,
SUM(player_stats.assists) as assists,
SUM(player_stats.goals+player_stats.assists) as points,
SUM(player_stats.minutes) as pim,
SUM(player_stats.xtra1) as xtra1,
SUM(player_stats.xtra2) as xtra2,
SUM(player_stats.xtra3) as xtra3,
SUM(player_stats.xtra4) as xtra4,
SUM(player_stats.xtra5) as xtra5,
ROUND(SUM(goals)/SUM(xtra4) * 100, 2) as sp,
COUNT(goals) as gp
FROM player_stats,teams,players WHERE teams.id = player_stats.team_id AND players.id = player_stats.playerid AND players.position != 'G' GROUP BY player_stats.playerid ORDER BY $order DESC,lname LIMIT $pageresultsstart,$pagelimit";