Hi,
I have a Web site for online golf (free, non-profit and international). I've been using a program
written by someone in PERL that allow players to report their scores and see the leader board updated instantly.
It also show stats and its very cool. However, it's not very friendly to use and is not MySql based.
So, I decided to write my own program starting from scratch using PHP-MySql. I did pretty good up to now
but I'm stuck on the leader board.
I want the leader board to show the players who completed the most rounds in first place in ascending order
according to their total score.
This is the MySql table:
CREATE TABLE results (
player int(4) NOT NULL default '0',
name varchar(150) NOT NULL default '',
country varchar(150) NOT NULL default '',
round1 char(3) default NULL,
round2 char(3) default NULL,
round3 char(3) default NULL,
round4 char(3) default NULL,
password varchar(25) default NULL,
PRIMARY KEY (player),
KEY name (name)
) TYPE=MyISAM;
Below is the sql command:
"SELECT results.player, results.name, results.country, results.round1, results.round2, results.round3, results.round4, SUM(results.round1+results.round2+results.round3+results.round4)
Here's what I get:
Position Player Name Country Score Round 1 Round 2 Round 3 Round 4 Total Score
1 71 Player1 GBR -16 56 56
2 100 Player2 USA -7 65 65
3 169 Player3 DEN -31 58 55 113
4 12 Player4 USA -22 56 66 122
5 26 Player5 USA -49 53 56 58 167
6 111 Player6 CAN -40 55 65 56 176
7 28 Player7 USA -55 60 68 55 50 233
8 29 Player8 USA -48 56 65 56 63 240
#-----------------------------------------------------------------------------------
"Score", "Position" and "Total Score" are variables. As you can see, the ranks are not in order. In fact,
players that have completed round 4 should be on top in ascending order. Then, these should be followed by
players who completed round 3, round 2 and round 1.
This is how it should appear:
Position Player Name Country Score Round 1 Round 2 Round 3 Round 4 Total Score
1 28 Player7 USA -55 60 68 55 50 233
2 29 Player8 USA -48 56 65 56 63 240
3 26 Player5 USA -49 53 56 58 167
4 111 Player6 CAN -40 55 65 56 176
5 169 Player3 DEN -31 58 55 113
6 12 Player4 USA -22 56 66 122
7 71 Player1 GBR -16 56 56
8 100 Player2 USA -7 65 65
#-----------------------------------------------------------------------------------
I saw someone who did something similar in ASP but he only shows the leader board round by round. I guess
he also found the same problem. I would like to show all players in the leader board that have completed
round 1 at least (Therefore: WHERE round1>0 ) but in the order above.
Could anyone help me with this?