在html表中显示mysql数据库[关闭]

I want to get all the data from my database and put it in a HTML table. My database looks like this:

username password q1 q2 q3 q4 q5 hscore lscore

I would like to get all of the usernames and put them with their hscore (stands for high score) with the highest highscore at the top and the smallest at the bottom. this is basicly a leaderboard. (the database is called users)

I had a go myself but I just couldn't get anything productive. if you need more info please ask.

Quick and dirty solution:

<?
echo '<table><thead><tr><th>Username</th><th>High Score</th></tr></thead><tbody>';
$q = mysql_query("SELECT username,hscore FROM TABLENAME ORDER BY hscore");
while($f = mysql_fetch_array($q)) {
    echo '<tr><td>'.$f['username'].'</td><td>'.$f['hscore'].'</td><tr>';
}
echo '</tbody></table>';
?>

TABLENAME should be replaced by your tables name. This is assuming that there is only one row for each user. You could use GROUP BY if you allow more than one record per user.