SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard frank1's Avatar
    Join Date
    Oct 2005
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    need a logic for this problem

    Scenario:
    i have made a point system for user

    ok system is like this
    a user is referred by some body to be member ..s/he send the link to friends like
    www.site.com/signup.php?ref=userid

    i have database table which has
    id name add,email,password,refferedby field...
    in that refferedby field the id of the person who has referred gets in and for every such refferral sign up the user(who has

    sent that signup link with id) gets some points.
    Interesting things begins here
    if the person who was referred by x (supppose y) refers it to somebody with his/her id ,/she she earns to point but at the

    same time the original referrer who has referred y (the x) also earns the points

    who ever below y makes member along with y x also gets points and so on..

    The problem:
    i was trying to display the total members made made by member (directly or indirectly,means by memebers made by me)
    so the simple logic i could think of is
    select * from table where referredby=userid;

    but as you know this will not solve the problem..as i get point of other members also who was referred by the people who were


    reffered by me and this query will only display people who were directly reffered by user of me.

    so how can i solve the problem?

    graphical view
    x-->y (reffred by x)-->z (reffred by x)
    when z becomes member, y as well as x earns point and so on in link...
    i am trying to calcuate points of x (or members made by x)

    i think i need a genuie loop for it but to be frank i thought and thought but seems like beyond reach of my mind

    what i hope to get:
    may be logic.....or some codes(of that loop will be great)
    by the way do i need to introduce additional field in database table

    any solution welcomed until it solves problem...

    thanks

    Note:I pray that i was able to make scenario clear...if i wasn't i am sorry and i hope i can make things clear in further

    posts in this topic..
    pray people have got it and there any be some logic genius to work out a innovative logic..or code..


    thanks

  2. #2
    SitePoint Wizard frank1's Avatar
    Join Date
    Oct 2005
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    from some days i have not been getting ans for my post so sad

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $$$

  4. #4
    SitePoint Wizard frank1's Avatar
    Join Date
    Oct 2005
    Posts
    1,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by 7stud
    $$$
    thats means u need dollars for answer?

  5. #5
    Passionate Web Developer Egyptechno's Avatar
    Join Date
    Jan 2004
    Location
    Dubai
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok .. this is a bit complicated



    First, you check if the refererid is empty or not ..

    if !empty .. then you go to the id



    when you get the id .. for the parent !

    you see if he is considered as son for another parent or not ( if here was refered too or not )
    so you have to check its refererid ..




    if it's empty .. then stop

    if not .. then take that id .. and go to check the userid ..

    and so on ..


    that's the general idea .. but you may need somethings to do it ..

    like : the number of parents !

    when everyone register under a user ( refered by him ) you add a new field + 1 ..

    so that , later when you are going to loop about points .. you could know the number of loops


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •