I have a table called user_extended in my DB, and one of the fields is user_referredby.
I also have a table called user, which holds the user_id and user_name.
Each record of the user_extended table will have some number in the user_referredby column. This number would be the user_id of whoever referred this person to the site.
What I want to do, is count the occurance of each number in the user_referredby column, and then have this data displayed to me so that I can see which user_id referred the most people.
Then somehow I would like to pull up the user_name that corresponds with the user_id, so that I will know how many people each user has referred without having to look up their username from the user_id.
So in the end of all this, I want to be able to display on a page how many people each person has referred. And order it so that the person who referred the most will be on the top. Something like this:
Bob has referred 150 people
Jane has referred 99 people
Mary has referred 40 people
Jack has referred 4 people
Jess has referred 0 people
Is there a way to do this?
Many Thanks!
I also have a table called user, which holds the user_id and user_name.
Each record of the user_extended table will have some number in the user_referredby column. This number would be the user_id of whoever referred this person to the site.
What I want to do, is count the occurance of each number in the user_referredby column, and then have this data displayed to me so that I can see which user_id referred the most people.
Then somehow I would like to pull up the user_name that corresponds with the user_id, so that I will know how many people each user has referred without having to look up their username from the user_id.
So in the end of all this, I want to be able to display on a page how many people each person has referred. And order it so that the person who referred the most will be on the top. Something like this:
Bob has referred 150 people
Jane has referred 99 people
Mary has referred 40 people
Jack has referred 4 people
Jess has referred 0 people
Is there a way to do this?
Many Thanks!







