You do not want to loop through every user and count their referrers! If you have 10,000 users, that would be 10,000 queries!
Why don't you work this into your hack instead:
Code:
SELECT COUNT(*) AS count, user.username, user.userid FROM user AS users
LEFT JOIN user ON (users.referrerid = user.userid)
WHERE users.referrerid <> 0
GROUP BY users.referrerid
ORDER BY count DESC
LIMIT 1
Referrals are done the way it is so that you can figure out what users a person has referred.
Also your code would appear to not work as you intended it to. You are trying to loop through all of the users and are using
numbermembers but that will not work for people with > 999 users as it will have commas added to it. You should use $numbersmembers[user] if you really want to do that. Your code took 40 seconds to execute on my site. My suggestion took .03 seconds.