Jump to content

Query help - loop member list


orionlogic

Recommended Posts

hi all,

I made a php system where members refers friends, and referred person is accepted,or declined, by the person who accepted the referrer.
Example:
Person A is accepted by Person B
Person A refers Person C to Person B
Person B accept Person C

member table update=> Person C addedby Person A

So as occurs a hierarchy from top down where people can see who is added the system by whom.

My question is: i can't solve the login behind this, also the way of presenting the memberlist in a top down hierarchy format.

Anyone have idea ?
Link to comment
https://forums.phpfreaks.com/topic/35098-query-help-loop-member-list/
Share on other sites

If you had 3 columns,  [ user, friend, referral ] , you could draw them out sorted any way you want.

[code]
Select * from people
order by referral asc , friend asc
[/code]

I imagine person C's record would be
[code]#user | friend | referral
#  C        B          A[/code]


I guess I don't really understand the exact result you are trying to get, but here's some bonus queries anyhow.

[code]
# friendliest people
select count(*) friends , friend
from people
group by friend
order by friends desc


#most referrals
select count(*) referrals, referral referring_person
from people
group by referral
having referrals>1
order by referrals desc
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.