How do I do this

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bodycount
Forum Newbie
Posts: 3
Joined: Wed Apr 14, 2010 8:52 am

How do I do this

Post by bodycount »

I am trying to run a 10 pin bowling league and I am trying to get a high score page for players and for teams. My problem is how do I get the high scores from three colums

|------------------| ------------------|------------------|
| Game 1 | Game 2 | Game 3 |
|------------------|-------------------|------------------|
200 190 150
191 170 201
189 180 175

I can do the following to get the highest score from each column individually

SELECT Game 1,PLAYERNAME FROM bowling.scores order by Game 1 desc;
result 200 player1 , 191 player2 , 189 player2

SELECT Game 2,PLAYERNAME FROM bowling.scores order by Game 2 desc;
result 190 player3 , 180 player1 , 170 player3

SELECT Game 3,PLAYERNAME FROM bowling.scores order by Game 3 desc;
result 201 player1 , 175 player1 , 150 player3

But what if the second highest score in Game 1 beats the highest score in Game 2. What do I do to sort this out?
ScOrPi
Forum Commoner
Posts: 44
Joined: Fri Jul 09, 2010 8:01 am
Location: BAGHDAD - IRAQ

Re: How do I do this

Post by ScOrPi »

Dear ,

u can always compare the results before inject it in database

just like

$query = "SELECT Game1 From Games";
$result = mysql_query($query);
$top = mysql_fetch_array($result);
$game1-first = $top['player1'];
$game1-second = $top['player2'];
$game1-third = $top['player3'];

now u'd saved the Top players for game 1 .. repeat for game2 and game3
then make conitions and start UPDATE the database ..

i hope that u'd understood me !
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: How do I do this

Post by mikosiko »

I will simplify doing two rankings:
1) Ranking by Game and
2) Ranking for accumulated points... and I will use this last one as the only order criteria if I choose to simplify further.
Post Reply