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
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.