Log in

View Full Version : Numbering an array of results?


N9ne
03-15-2003, 06:22 PM
$gettop10 = $DB_site->query("SELECT userid,username,qualitypoints,posts FROM user ORDER BY qualitypoints DESC LIMIT 10");
while($thetop10 = $DB_site->fetch_array($gettop10)) {
$userid = $thetop10[0]; $username = $thetop10[1]; $qualitypoints = $thetop10[2]; $posts = $thetop10[3];



I have that code, now I would like to also display a number beside each result when I echo them...Ie. 1, 2, 3, 4, etc...

Is that possible without adding some sort of auto_increment field in the database or something complicated? :p

filburt1
03-15-2003, 06:25 PM
Add a counter:

$gettop10 = ...;
$i = 0;
while (...)
{
.
.
.
$i++;
}

The counter will stop at mysql_num_rows() - 1.