I m working on a MLM project in which i have to store member automatically in binary tree form like

1 is root
2 is child of 1
3 is child of 1

Then 4 is child of 2
5 is child of 2

6 is child of 3
7 is child of 3

then 8 is child of 4

and so on ......

can any body help me

Do you want to have it self balancing?
If you don't care (little slower) then you should write a Binary Tree class with a generic add method adds the children to the correct position by looping through the tree and checking where it goes.

I guess it depends on how big your tree is going to be. If you're going to have a lot of records in your tree then you should try to find a self-balancing class that's written in php (or in another language like C++ and adapt it). If it's not going to be that large (maybe 20 records or so at a time) then you can just do an un-balanced tree.

Hi want to create a binary tree using table registration having fields id, parent_id, user_name.
id Parent_id user_name
1 0 SF8011049
2 1 SF6542248
3 1 SF2998128
4 2 SF2518457
5 2 SF7055311
6 3 SF0207585
7 3 SF6258770

Please tell how to create binary using this table. Please any body help me to display binary tree having username in the tree structure. Please help me.

Please quick replay