1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

php multi level marketing

Discussion in 'PHP' started by kengboon, Apr 6, 2009.

  1. #1
    Hi everyone, I'm a newbie here.

    Recently I'm doing a MLM system.

    members | upline
    2 | 1
    3 | 2
    4 | 3
    5 | 3
    6 | 2
    7 | 3
    8 | 7
    9 | 5
    10 | 3
    11 | 10
    12 | 3
    13 | 10
    14 | 2
    15 | 14
    16 | 10
    17 | 9
    18 | 9
    19 | 9
    20 | 19

    A chart like this, I want to know the whole members under the member No.1 and each level got how many members? Anyone can help me? Please advise and HELP..thanks..

    below is my coding to find out all member under one member.

    $downline = getdown($upline);
    function getdown($upline){
    $sql = "select * from TABLE where upline = '$upline'";
    $rs = mysql_query($sql) or die(mysql_error());
    $count = mysql_num_rows($rs);

    if($count > 0){
    for($j=0; $j<$count; $j++){
    $get = mysql_fetch_array($rs);
    $arr[$j] = $get['id'];
    }
    for($x=0; $x<count($arr); $x++){
    getdown($arr[$x],$count);
    }
    }
    }

    INPUT
    $downline = getdown(1);
    function getdown($upline){
    $sql = "select * from TABLE where upline = '$upline'";
    echo $sql."<br>";
    $rs = mysql_query($sql) or die(mysql_error());
    $count = mysql_num_rows($rs);
    echo "<b>"."~"."$count"."~"."</b>"."<br>";

    if($count > 0){
    for($j=0; $j<$count; $j++){
    $get = mysql_fetch_array($rs);
    $arr[$j] = $get['id'];
    echo $arr[$j]."<br>";
    }
    for($x=0; $x<count($arr); $x++){
    getdown($arr[$x],$count);
    }
    }
    }

    OUTPUT
    select * from TABLE where upline = '1'
    ~1~ (FIRST LEVEL 1 MEMBER)
    2
    select * from TABLE where upline = '2'
    ~3~ (SECOND LEVEL 3 MEMBERs)
    3
    6
    14
    select * from tblmember where upline = '3' and status = 1
    ~5~ (THRID LEVEL 5 MEMBERs)
    4
    5
    7
    10
    12
    select * from tblmember where upline = '4' and status = 1
    ~0~ (FOURTH LEVEL NO MEMBER)
    select * from tblmember where upline = '5' and status = 1
    ~1~ (FOURTH LEVEL 1 MEMBER)
    9
    select * from tblmember where upline = '9' and status = 1
    ~3~ (FIFTH LEVEL 3 MEMBERs)
    17
    18
    19
    select * from tblmember where upline = '17' and status = 1
    ~0~ (SIXTH LEVEL NO MEMBER)
    select * from tblmember where upline = '18' and status = 1
    ~0~ (SIXTH LEVEL NO MEMBER)
    select * from tblmember where upline = '19' and status = 1
    ~1~ (SIXTH LEVEL 1 MEMBER)
    20
    select * from tblmember where upline = '20' and status = 1
    ~0~ (SEVENTH LEVEL NO MEMBER)
    select * from tblmember where upline = '7' and status = 1
    ~1~ (FOURTH LEVEL 1 MEMBER)
    8
    select * from tblmember where upline = '8' and status = 1
    ~0~ (FIFTH LEVEL NO MEMBER)
    select * from tblmember where upline = '10' and status = 1
    ~3~ (FOURTH LEVEL 3 MEMBER)
    11
    13
    16
    select * from tblmember where upline = '11' and status = 1
    ~0~ (FIFTH LEVEL NO MEMBER)
    select * from tblmember where upline = '13' and status = 1
    ~0~ (FIFTH LEVEL NO MEMBER)
    select * from tblmember where upline = '16' and status = 1
    ~0~ (FIFTH LEVEL NO MEMBER)
    select * from tblmember where upline = '12' and status = 1
    ~0~ (FOURTH LEVEL NO MEMBER)
    select * from tblmember where upline = '6' and status = 1
    ~0~ (THIRD LEVEL NO MEMBER)
    select * from tblmember where upline = '14' and status = 1
    ~1~ (THIRD LEVEL 1 MEMBER)
    15
    select * from tblmember where upline = '15' and status = 1
    ~0~ (FOURTH LEVEL NO MEMBER)

    By using the same coding, I be able to know the total member for selected member.
    The problem I facing here is I unable to sum the amount in the sam level.
    For example, I want to know got how many members in Level 4, the total is 0 + 1 + 1 + 3 + 0 + 0 = 5 members in Level 4.

    But I dunno how to use my coding to SUM it, anybody can help me? thanks ya..
     
    kengboon, Apr 6, 2009 IP
  2. parthiphp

    parthiphp Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi

    I have somuch knowledge in MLM project.

    See I worked on the binary concept, trinary concept, tail concept, sunflower, and level concept(same like your's concept).

    First I want to saw the database design then only I will say the solution. Otherwise change the table design for sponsorID

    You cant understand the above lines or any queries contact me.

    I will give the good solution

    Regards
    Parthiban
     
    parthiphp, Apr 6, 2009 IP
  3. kengboon

    kengboon Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi Parthiban,

    Hopefully you be able to help me in this situation.

    On my tablemember, it got the fields memberid, member profile details, uplineid.

    So that means all my details is just store in this tables.

    What I want now is when I select the memberid 2, all the member which got the relationship with 2 will show out. I hope be able to get the output like first level got how many members, the members is who who who, then second level got how many members, the members is who who who..

    Please advised.. Thanks..
     
    kengboon, Apr 8, 2009 IP
  4. parthiphp

    parthiphp Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi

    Your table design is wrong thats why you cant get the details.
    Change the table design

    Like (Memberid, level1(sposnor), level2, level3, etc...)

    for further details

    Come to Yahoo IM..
    nparthi2006
     
    parthiphp, Apr 9, 2009 IP
  5. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #5
    hi .. please tell us the solution in here.. so we can learn toghether :)

    regards
     
    ghprod, Apr 12, 2009 IP
  6. parthiphp

    parthiphp Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi

    This is only for 5 matrix concept.
    Create the table

    Table Name : tbl_levels

    Columns : Memberid, level1, level2, level3, level4, level5

    When you registered time insert the memberid on this table and also insert sponsorid in level1, and you that sponsorid and that levels same. So you insert same ID values of remaining levels.
     
    parthiphp, Apr 12, 2009 IP
  7. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #7
    it's seems like this is a complicated script :(

    regards
     
    ghprod, Apr 14, 2009 IP
  8. parthiphp

    parthiphp Peon

    Messages:
    16
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    no, its very simple
     
    parthiphp, Apr 16, 2009 IP
  9. kengboon

    kengboon Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9

    Hi Bro,

    Sorr for late reply. Recently I busy on server setting so not free to come here.
    About your recommend, I think quiet a bit hard to do. You means my table design need like

    Memberid, level1, level2, level3, level4, level5, level6, level7 .......................

    My system is unlimited level and I need to count the total user in every level.
    If I design the table as you recommend, then I think the table will become very very big due to the data we store is too many. Then if I want calculate out one things, is it the looping will make my server loop until die?

    Jialat..i still stuck at there..dunno how to continue this system..
     
    kengboon, Apr 17, 2009 IP