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