HOw do I get PHP/MySQL output in a table to be numbered?

  • Thread starter Thread starter falcon_developer
  • Start date Start date
F

falcon_developer

Guest
have a MySQL DB that has a DB w/ one table, that having two rows. I use this PHP to retrieve it and put it into a table (It's for hi-scores):

$fetch = mysql_query("SELECT * FROM scores ORDER BY score DESC LIMIT 10");



while($row = mysql_fetch_array($fetch))
{
echo "<table border='1' width=300><tr><td>&nbsp $row[name] &nbsp</td><td>&nbsp $row[score] &nbsp</td></tr></table>";

}

I would like to have each horizontal row have a number before it, numbered 1 - 10 (it's a hi-score platform). How would I do that? Keep in mind that I don't want them numbered as they are in the DB, but as they are sorted and listed on the page. Help?

The page is here:
http://pennyontherail.com/score10.php .

Thank you very much!
 
Just make a counter.

Pseudocode

i = 1
echo table
foreach row
echo i
echo field name
i++
end foreach
echo /table
 
Back
Top