What you want here is an increment counter in the SQL:
There are two ways of doing this:
First:
set @rownum := 0;
And then
SELECT id, leaderfirst.pictureid, leaderfirst.point,
FIND_IN_SET( leaderfirst.point,
( SELECT GROUP_CONCAT(
leaderfirst.point ORDER BY leaderfirst.point DESC
)
FROM leaderfirst )
) AS rank,
@rownum := @rownum + 1 AS row_number
FROM leaderfirst
ORDER BY row_number
Or:
Combining the first two queries together you can use :
SELECT id, leaderfirst.pictureid, leaderfirst.point,
FIND_IN_SET( leaderfirst.point,
( SELECT GROUP_CONCAT(
leaderfirst.point ORDER BY leaderfirst.point DESC
)
FROM leaderfirst )
) AS rank,
@rownum := @rownum + 1 AS row_number
FROM leaderfirst
CROSS JOIN (select @rownum := 0) r
ORDER BY row_number
Source: This answer here.
There are also various variaton on this theme.
Solution 2:
simply ignore trying to generate this data with your MySQL; you said you don't care about order, simply the auto-increment nature of the resultant ranking; therefore you can do something like this if you're using PHP (and similar work in other languages):
Pseudo-code below:
$mysqlDataOutput = mysql result data from your SQL . "ORDER BY rank DESC";
$counter = 0;
foreach($mysqlDataOutput as $resultRow){
print $counter.") ".resultRow['points']. " -
<img src='".$resultRow['pictureid']."' alt=''>";
$counter++;
}
unset($mysqlDataOutput, $resultRow);
If you want to order the other way around (lowest rank first) then simply invert your SQL ORDER BY
and set:
$counter = count($mysqlDataOutput);
foreach(){
...
$coounter--;
}