My problem is I need to return the list of each 'game_id' where the 'user_id' is in the top three of 'score' and his position. My mysql table is as follows:
pk_hiscore_id
game_id
user_id
score
How would I do this?
My problem is I need to return the list of each 'game_id' where the 'user_id' is in the top three of 'score' and his position. My mysql table is as follows:
pk_hiscore_id
game_id
user_id
score
How would I do this?
Use this query and mysql_fetch_assoc
the result:
SELECT * FROM `table_name` ORDER BY `score` DESC LIMIT 0,3
Then, loop through the resulting array like this:
// Assume that $array is the array you loaded the query result into.
for ($position = 1; $position <= 3; $position ++)
{
$game_id = $array[$i-1]["game_id"];
echo "Game ID: " . $game_id . "
";
echo "User Position: " . $position;
}
Unless I am understanding you incorrectly, that should give you the information you want.