Your table design sounds
very questionable to me. That's Ok as long as it works for you, but it may lead you to many problems down the road. Check out the concept of "database normalization" in a database book or on the web.
With that said, the SQL for your request is pretty simple. I'm pretty sure that you want:
PHP Code:
SELECT Count(*), referrer, lastname, firstname
FROM myTable
GROUP BY referrer, lastname, firstname
ORDER BY Count(*) DESC, referrer DESC
The PHP side is another story. I'm not strong there, so I'll let you post those questions in the
PHP Forum where you can get some PHP opinions!
-PatP