moneygrinch Posted March 18, 2007 Share Posted March 18, 2007 Does anyone know how to keep track of uplines using PHP Mysql? I am trying to keep track by haveing each new person have an upline number. Then looking for that number to know the uplines downlines. Any thoughts to make this easier? Link to comment https://forums.phpfreaks.com/topic/43287-mlm-geneology/ Share on other sites More sharing options...
AndyB Posted March 18, 2007 Share Posted March 18, 2007 Give each person a 'parent_id' that corresponds to the id of person one up Link to comment https://forums.phpfreaks.com/topic/43287-mlm-geneology/#findComment-210183 Share on other sites More sharing options...
moneygrinch Posted March 18, 2007 Author Share Posted March 18, 2007 Yeah, i did that for sure. I can pull the records of all the people in 1 level of the downline. That was the easy part. The issue is going that next level down. Example: Level 1 has only 1 parent. So there may be say 5 subs. Now in order to figure out the subs for these 5 parents I have to SELECT for these 5. I came up with this but it is poor. Only the level one works. // upline figuration //Level 1 $level_1 = @mysql_query("SELECT member_id FROM call_center WHERE upline_id={$_SESSION['member_id']}"); $level_1a = mysql_fetch_array($level_1); $upc = mysql_num_rows($level_1); if($upc > 0){ $upc = $upc; }else{ $upc ="None"; } //Level 2 while($level_1a = mysql_fetch_array($level_1, MYSQL_ASSOC)){$level_2 = @mysql_query("SELECT member_id FROM call_center WHERE upline_id=$level_1a[member_id]"); echo $level_2;} $upc_2 = mysql_num_rows($level_2); if($upc_2 > 0){ $upc_2 = $upc_2; }else{ $upc_2 ="None"; } //while($level_1a = mysql_fetch_array($level_1, MYSQL_ASSOC)){$lvl_1 = $level_1a["member_id"];} //$level_2 = @mysql_query("SELECT member_id FROM call_center WHERE upline_id=$lvl_1"); What can I do to search for more than one parent at once? Link to comment https://forums.phpfreaks.com/topic/43287-mlm-geneology/#findComment-210213 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.