I’m fetching data from a MYSQL database I’ve created which stores a players statistics I.E. kills, deaths, ratio. I have fetched all of the data and made it into a table format in my PHP lines of code but I’d like to know (since im very new to PHP) how I could possibly make it so that the top number of kills go above in the table and the number ‘id’ changes for every player regarding their rank.
Here are the lines of codes:
echo "<table width='1000' cellpadding='10' cellspacing='5' border='1'>";
echo "<tr
<td><center><b>RANK</td></center></b><td><b><center>Nickname</td></center></b><td><center><b>Kills</td></center></b><td><center><b> Deaths</td></center></b><td><center><b>Ratio</td></center></b></tr>";
while($info = mysql_fetch_array( $data ))
{
echo "<tr>
<td><center><b>".$info['id']."</td></center></b>"."<td><center><b>".$info['username']."</td></center></b>"."<td><center><b>".$info['kills']."</td></center></b>"."<td><center><b>".$info['deaths']."</td></center></b>"."<td><center><b>".$info['ratio']."</td></center></b></tr>";
}
echo "</table>";
You can append an
order by kills descto your SQL statement so the max kills is first.