I am doing a project for a new company. WIthout telling you too much (the company would fire me), I'll give a simplified explanation of what I'm trying to do...
Users sign up on the web site. Other users will sign up with referrals from other users. Basically creating a pyramid. Assume there is a somewhat standard 'users' table. Here is the
'refs' table :
Table : Refs
id INT // this is the primary key
user_id // this is a foreign key that is linked to users
who // the user_id of a person signed up "under" this person
Here is the query I use to extract one "level" of users.
select users.name, users.id, refs.who from users
inner join refs on refs.userid = users.id where
users.id = 'someuserid';
And that returns the people signed up by user 'someuserid'
And I need to go through all of the people signed up under this user, and do the same thing until there are no more sign ups.
I am just wondering if there is a better query I can use, and what the PHP code might look like that would make these iterations.
Any help is appreciated.
Let me know if I clarified this enough.
-silent