I have been trying to find something about this topic and I can't seem to find anything, there were a few questions on here but they didn't work for my particular project.
I asked a similar question about updating the table but its not going to work for what I actually want
here is the list of result.
--------------------------------------------------------
|id | hometeam |goalsfor|goalsagainst| awayteam |
--------------------------------------------------------
| 1 |Inter Milan | 3 | 1 | FC Barcelona |
--------------------------------------------------------
| 2 |FC Barcelona | 1 | 0 | Inter Milan |
--------------------------------------------------------
| 3 |Inter Milan | 4 | 0 | AC Milan |
--------------------------------------------------------
| 4 |AC Milan | 0 | 2 | Inter Milan |
--------------------------------------------------------
| 5 |Real Madrid | 2 | 0 | AC Milan |
--------------------------------------------------------
| 6 |AC Milan | 2 | 2 | Real Madrid |
--------------------------------------------------------
| 7 |FC Barcelona | 2 | 2 | AC Milan |
--------------------------------------------------------
| 8 |Real Madrid | 2 | 0 | Inter Milan |
--------------------------------------------------------
| 9 |Inter Milan | 3 | 1 | Real Madrid |
--------------------------------------------------------
| 10 |FC Barcelona | 2 | 0 | Real Madrid |
--------------------------------------------------------
| 11 |Real Madrid | 1 | 1 | FC Barcelona |
--------------------------------------------------------
Basically I want to be able to create a standings table ranking the teams in order, I want to present this table on the fly and not put it into the database
Pos Team Pld W D L F A GD Pts
1 FC Barcelona 5 2 3 0 8 5 3 9
2 Inter Milan 6 2 2 2 11 10 1 8
3 Real Madrid 6 2 2 2 8 8 0 8
4 AC Milan 5 0 3 2 8 12 -4 3
POS=Position W=won D=Draw L=Loss F=Goals scored For A=Goals scored against GD=Goals difference Pts=Points
I think the most efficient way to do this would be to assign wins, draws and losses, sum the goals scored and goals scored against and when echoing out the data - calculate the total number of games played and the points.
But how would I assign wins draws or losses? And calculate the goals scored and goals against?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…