Jibin Prabhakar
Jibin Prabhakar

Reputation: 11

binary tree implementation in php and mysql(genealogy)

I am trying to do an MLM project in PHP. Now I'm stuck on the binary tree representation of MLM. Please help me to implement the tree.sample tree structre. Please help me to build a tree-like on the attached image.

Sample tree structre

Upvotes: 1

Views: 1999

Answers (1)

HKS
HKS

Reputation: 11

you can easily create a tree structure in php with function. Tree create a table or any form you can display a tree, but its best for me for displaying a mlm binary tree structure in php.

$userid = $_SESSION['userid'];

its your login id...

function tree_data($userid){

global $con;

$data = array();

$query = mysqli_query($con,"select * from tree where userid='$userid'");

$result = mysqli_fetch_array($query);

$data['userid'] = $result['userid'];

$data['left'] = $result['left'];

$data['middle'] = $result['middle'];

$data['right'] = $result['right'];

$data['leftcount'] = $result['leftcount'];

$data['rightcount'] = $result['rightcount'];

return $data; }

you can easily show a tree in table format with the help of above function. like $userid your root and so..

Upvotes: 1

Related Questions