Hope someone can help I'm struggling with a bit of code.
From my game web site, I use this code to show players positions within a 'league table'.
$query="SELECT * FROM table ORDER BY current_score DESC";
$result = mysql_query($query) or die(mysql_error());
$position = 1;
$count = 0;
$current_point_score = 0;
while($row = mysql_fetch_array($result))
{
$count++;
if($row["current_score"] < $current_point_score)
{
$position++;
$position = "$count";
}
$current_point_score = $row["current_score"];
echo $position;
echo "<br />";
}
However aswell as displaying the league position, for each player, on the table page I would also like to update the DB with each players own position.
I tried this code, but all the rows were updated with the final position.
$result = mysql_query("UPDATE table SET league_position ='$position' ORDER BY current_score DESC");
Does anyone know a way around this, so each row is updated in accordance with the current score of each player.
Thanks
Jon