PHP Count/Group By Top Occurrences Of Data In mySQL
$30-100 USD
Completed
Posted about 16 years ago
$30-100 USD
Paid on delivery
Basically this is what I need...
I already have users in a database who are each given a unique id number
(1-whatever). These people refer others to my site through their id number
and when they do, their id number, the name, email address of anyone
they refer and datetime is also stored in the same database but in a different table.
I need a way to list who has referred the most people along with the
number of people they have referred.
For example...
If I click a button that says... "Show Me The Top 10 Referrers", the php
code you write would query my database and list the top ten people who
have the most number of referrals associated with their id numbers.
The output should be something like...
First Place: John has referred 93 people
Second Place: Jane has referred 75 people
Third Place: Steve has referred 73 people
etc
If more than one person has the exact same number of referrals, they
should be given the same position.
For example...
First Place: John has referred 93 people
Second Place: Jane has referred 75 people
Third Place: Steve has referred 73 people
Third Place: Jesse has referred 73 people
Third Place: Tom has referred 73 people
Fourth Place: Rachel has referred 71 people
Fifth Place: Robin has referred 69 people
etc
In the example above, all of the referrers also have their email address
stored in the same line as their name. I need for their names to be
clickable so that I can send each of them an individual email.