Jump to content

Max Score, for each game


KingOfHeart

Recommended Posts

I want to get the max score for each game (which I got working) but I need it to display the proper "name".

 

function UpdateArcade()
{
$sql = mysql_query("Select id, game, timedate, name, MAX(score) FROM HighScores Group By game");
while($row = mysql_fetch_array($sql)) {
	echo "Game: " . $row['game'] . "<br>";
	echo "Score: " . $row['MAX(score)'] . "<br>";
	echo "Time: " . $row['timedate'] . "<br>";
	echo "Name: " . $row['name'] . "<br>";
	echo "<p>";
}
}

 

One of my OutPuts.

 

Game: 3

Score: 642 < correct

Time: 20090201045121 < wrong as well

Name: Affen < wrong, he did not even make a score in this game

 

So what's wrong here?

Link to comment
Share on other sites

For the time issue im guessing you're using mktime() ? Or something to give back the unix. You could do this:

function UpdateArcade() {
$sql = mysql_query("Select id, game, timedate, name, MAX(score) FROM HighScores Group By game");
while($row = mysql_fetch_array($sql)) {	
	$today = $row['timedate'];
	$time = $today['month'] . " " . $today['mday'] . ", " . $today['year'];
	$time .= " " . $today['hours'] . ":" . $today['minutes'] . ":" . $today['seconds'];

	echo "Game: " . $row['game'] . "<br>";
	echo "Score: " . $row['MAX(score)'] . "<br>";
	echo "Time: $time <br>";
	echo "Name: " . $row['name'] . "<br>";
	echo "<p>";
}
}

 

Is the max score the highest scored value by certain player? because if you're grouping by game, it's gunna group all that data and pick the Max Score obviously but it'll choose the first name.

 

Maybe you could try.

 

 $sql = mysql_query("Select * FROM HighScores ORDER BY score DESC"); 

 

This will output like:

 

GAME: UNO - SCORE 1000 - TIME: 12/3/2007 12:13:53 - NAME: Bob.

GAME: CROSS - SCORE 800 - TIME: 12/3/2007 12:13:53 - NAME: Peter

GAME: UNO - SCORE 710 - TIME: 12/3/2007 12:13:53 - NAME: Bob

 

And so fourth. I don't know if that is specifically what you're after though.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.