0

In short, a leaderboard.

The person with the highest coins wants to be listed, first. listing the top 10 only, based on the highest coin count joined with their username.

This lists the usernames, but not sure how to get their coins count, as well as ascend them in a top 10 formation.

<?php
$query = mysql_query("SELECT username FROM `users`");

echo '<table>';
while($rowtwo = mysql_fetch_array($query)){
    echo    '<tr>
            <td><font size="2" face="Lucida Sans Unicode" color="red">'.$rowtwo['username'].'</td>
            </tr>';
}
echo '</table>';
?>
  • Fixed this. '; while($rowtwo = mysql_fetch_array($query)){ echo ' '.$rowtwo['username'].' '.$rowtwo['coins'].' '; } echo ''; ?> – user2305310 Apr 21 '13 at 23:56

2 Answers2

2
SELECT username FROM `users` ORDER BY coins DESC LIMIT 10

The DESC is important or else it will list coins in order of lowest to highest. This also assumes that coin count is a column of users. If it's not, you'll have to let me know.

Explosion Pills
  • 188,624
  • 52
  • 326
  • 405
1

Change the query to:

SELECT username FROM `users` ORDER BY `coins` DESC LIMIT 0,10
hek2mgl
  • 152,036
  • 28
  • 249
  • 266
  • You are welcome! Btw, why named you the record `$rowtwo` ? Wouldn't `$user` be a more descriptive variable name? – hek2mgl Apr 21 '13 at 23:58