Hi,
I am not sure how you have organized your database.
But to me it sounds like you are doing something fairly straightforward i a complex way.
I assume you have a table which holds scores per per person per match?
You could then do something like:
$query = "
select name, sum('scored') as total_scored from table group by name order by total_score
";
which would toss out all your variable-variables, math's etcetc and give you hte output you need.
Have a look at the mysql website and look for select in the manual.
If I am completely off here.. you can do this:
Instead of echo-ing all to the screen, place each name & score in an array(). Then sort the arrays.