Buongiorno a tutti! All'interno del mio database mysql ho una tabella chiamata "scores" che contiene tre colonne: "id","name","score". Da notare che nella tabella non ci potranno mai essere due nomi uguali. Ora vorrei, con uno script php che riceve in ingresso uno specifico nome contenuto nel db, calcolare quale sia il numero di riga in cui questo nome si trova sapendo che la tabella deve essere ordinata per "score" DESC. Per esempio, nel caso in figura:
se il nome corrente č "LEVELs" il risultato sarā 4, mentre se il nome č "alektab7.0" sarā 5.

Ho provato con il seguente script php che funziona perfettamente tranne proprio nel caso sopra riportato, ovvero quando due nomi hanno lo stesso punteggio. (Nel caso di "LEVELs" e "alektab7.0" per entrambi il risultato č 4!!!).
Codice PHP:
<?php
include("common.php");
    
$link=dbConnect();

    
$name safe($_POST['name']);

    
// gets all the records with higher or equal scores than current user
    
$ranking mysql_query("SELECT count(*) + 1 AS ranking FROM scores WHERE score > (SELECT score FROM scores WHERE name = '$name' ORDER BY score DESC LIMIT 1)");
    
// creates an array from the mysql query above
    
$ranking_array mysql_fetch_assoc($ranking); 
    
// gets the number of higher scores from the array
    
$ranked_above $ranking_array['ranking']; 
    
// takes the total number ranked above
    
$current_rank $ranked_above;
    echo 
$current_rank;
?>
Grazie mille a chiunque potrā aiutarmi!!!