KingOfHeart Posted April 7, 2009 Share Posted April 7, 2009 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? Quote Link to comment Share on other sites More sharing options...
viion Posted April 9, 2009 Share Posted April 9, 2009 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. Quote Link to comment Share on other sites More sharing options...
xtopolis Posted April 10, 2009 Share Posted April 10, 2009 Table structures and sample data would help us a lot. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.