Matrix (3 Position) MLM Tree in PHP

649 Views Asked by At

Tables

I have these two tables in my database. 'Members' contains member id and names of memebers and 'Network' contains member_id and the id of members at their first, second and first place.

I want to create a loop where I will be putting member id and the loop will give me all his downline members with ids and their network. The expect result is attached here with.

If you have any other idea to do that, the idea is welcome. Thank you very much in advance.

Result

1

There are 1 best solutions below

1
On

In computer science, a ternary tree is a tree data structure in which each node has at most three child nodes, usually distinguished as "left", “mid” and "right". Nodes with children are parent nodes, and child nodes may contain references to their parents. Wikipedia Your data structure is completely wrong make your table like this

`Table structure will be uid,uname,rid,pid,left_leg,mid_leg,right_leg,status from members`

I am not sharing the username,password,email because these are the general things you can do it well please if you do not understand then comment me so I will provide you will details for your table structure.