Copy link to clipboard
Copied
As you can probably tell, I am not sure of what I am asking here, and as a result I can't find it on google.
How do I add a number to results returned from a recordset? I am goiing to need to display a highest score first descending to the lowest last, but I need to display where each score is positioned... like so:
1. John scored 6769
2. Bill scored 5698
3. Annie scored 5046
4. Frank scored 4908
5. Mary scored 4725
6. Tom scored 3375
7. and so on...
It'll be for PHP and MySQL.
Thanks.
Mat
I found what I was looking for...
It's MySQL's 'rank' function.
Here's the code if anybody needs it:
SELECT @curRank := @curRank + 1 AS rank, db_fld_colname, db_fld_score
FROM db_table, (SELECT @curRank := 0) r
ORDER BY db_fld_score DESC
Copy link to clipboard
Copied
I found what I was looking for...
It's MySQL's 'rank' function.
Here's the code if anybody needs it:
SELECT @curRank := @curRank + 1 AS rank, db_fld_colname, db_fld_score
FROM db_table, (SELECT @curRank := 0) r
ORDER BY db_fld_score DESC
Find more inspiration, events, and resources on the new Adobe Community
Explore Now