I have a MySQL database with a table called subm_items
The table contains the following columns (item_id, score)
E.g.
+---------+-------+
| item_id | score |
+---------+-------+
| 1 | 20 |
| 2 | 30 |
| 3 | 5 |
| 4 | 10 |
| 5 | 80 |
+---------+-------+
I would like to be able to preform a query (AND DISPLAY THE RESULTS IN PHP) that determines the "rank" or "position" of an entry based on the score of an item compared to the score of all the other items.
For example if I pass item_id '5' (with a score of 80) it should return a rank of 1.
If I pass item_id '3' (with a score of 5) it should return a rank of 5.
IMPORTANT NOTE: If someone would be willing to provide me with not only the MySQL query but also how to display the results of the Query in PHP (using a variable for example) that would be great! I have come across this question in other posts but no one has provided how to actually use and display the results from the query in PHP.
Thanks!