kengboon Posted April 7, 2009 Share Posted April 7, 2009 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.. Link to comment https://forums.phpfreaks.com/topic/152919-php-multi-level-marketing-looping/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.