开发者

Creating Soccerleagueranking with Codeigniter & Mysql

I've searched the site for similar posts but i found just one where the developer tried to do his calculations (win-lose-draws) with an enormous SQL query. I would like to do the calculations in my controller but don't really know where to start.

I have 2 tables which look like this:

Teams

teamID     teamName

Games

gameID     matchday     homeTeamID     awayTeamID    homeScore     awayScore

Now i'm trying to produce a league ranking out of this match results, But i need some insights on how to look at this...

A开发者_如何学运维t the moment, I have a query which selects all the match results and assigns the correct teamID's to the home or away Team like this:

"SELECT g.gameID, g.matchday, g.homeTeamID, g.awayTeamID, g.homeScore, g.awayScore, th.teamName as homeTeam, ta.teamName as awayTeam,
FROM games AS g
INNER JOIN teams as th ON g.homeTeamID = th.teamID
INNER JOIN teams as ta ON g.awayTeamID = ta.teamID
JOIN submenu_teams AS s ON g.submenuID = s.submenuID"

Can anybody try to explain where to go from here to get a nice ranking of the teams according to how many points they won during the season?

Thnx!


I would suggest to keep track of the points in a table (season1) so that every time a page is requested, you don't have to compute the rankings again : you just fetch from the table.

Everytime a new match is played, run a script that adds X point to winner and substracts Y points from loser.

To display, fetch the results and order by score.

You're done !

(was it my post that you read on rankings and SQL ?)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜