php - Complicated MySQL Query for MLM Business -
i've got confused @ moment.
i've got 1 database developed mlm (multi level marketing) company. so, there's 1 members database.. each member have unique id called membercode.. , members have members under them.. every member have 3 members under him/her.. , 3 members can have same under them.. members added in same database table named "tbmembers" , each member there's "parentid" add member's membercode under whome member is?.. right?
now question .. want sql query can go under , under.. 'john doe' having 3 members under him named 'suzan' , 'ellie' , 'smith'. , 'suzan' having 3 members under her.. , same ellie. , example.. 'john doe' having 300 members in down line? , gets paid member adds 3 members under downline, member adds 3 members paid , upline members paid amount of money. can downline level number of member under 1 particular member?? , can calculate earnings based on 3 members joining under him.
i'm using php , use my-sql. how it? please me out guyz.
i dont know table structure algorithme:
here php code
function get_recursive_users($pid) { $users = //get query users parentid= $pid; /*for example db::query('select * `members` parentid="'.$parentid.'"');*/ foreach($users $user) { return get_recursive_users($user['pid']); } } $parentid = 'your current user pid' get_recursive_users($parentid);
Comments
Post a Comment