Good,
I do not understand very well the question, what has already done or what type of database ... But I'll try to give some tips:
After connecting to the database (I assume you already have it done) you need to do the query (Here in MySQL) ...
I think what you want is:
$query="SELECT * FROM tb_user ORDER_BY referrals DESC"
Then you need to query:
$result=mysqli_query($link, $query);
And collect the result
$count=1;
while ($pessoa = mysqli_fetch_assoc($result)) {
echo $count."º ".$pessoa["nome"]." - Tem ".$pessoa["referrals"]." indicados.<br>";
$count++;
}
Well, if I do not have any syntax errors (I have not used this for some time), I believe this is it!