Hi,
just to understand:
can a user insert more than one name (if e.g. the user told 5 persons about the forum) ?
If this is the case I would suggest the following change:
User table:
USER:
userid------------username
1------------------admin
2------------------june
3------------------tom
4------------------bush
5------------------_
6------------------zing
7------------------zong
8------------------zung
Then you could have a second table:
REFERRAL:
olduserid--------newuserid
1------------------5
1------------------4
1------------------3
5------------------2
3------------------6
3------------------7
3------------------8
(with an unique index using both fields olduserid and newuserid)
If you want to get the top 5 the query could look like:
SELECT count(u.userid) as cnt,u.userid,u.username
FROM USERS u,REFERRAL r
WHERE u.userid=r.olduserid
GROUP BY u.userid ODER BY cnt DESC,u.userid DESC LIMIT 5
Use LIMIT 5 if you want to limit the numbers of rows in the result set.
The tricky part would be to make sure that cross references don't exist like user 1 inserted user 2 and user 2 inserted user 1 which might not be what you want.
I hope that the query is correct...
Thomas