I have hierarchical data of family in nested array. I want to draw tree using php graphics. Any body have some code, Please help me how to draw tree nodes & links between nodes etc

Thanks,

I have hierarchical data of family in nested array. I want to draw tree using php graphics. Any body have some code, Please help me how to draw tree nodes & links between nodes etc

Thanks,

hi did u ever get help on this? I need the same thing. thanx

Member Avatar

diafol

There are lots of ajax trees out there that you can modify (css). I don't know if GD would be the way to go. Creating a new graphic with GD everytime may be costly w.r.t. processing.

There are lots of ajax trees out there that you can modify (css). I don't know if GD would be the way to go. Creating a new graphic with GD everytime may be costly w.r.t. processing.

Thanks, lemme look at the Ajax Trees. Can you also give a link example.

Thanx but i was looking for a binary tree loader of some sort. Something like that: http://frank-mich.com/jQuery/

This one's nt very helpful cuz its starting at the bottom.

Thanx a lot

Member Avatar

diafol

I take it you're not looking a file/folder tree. Your just after a hierarchy script I take it? Like a family tree type thingy?

yes something like http://frank-mich.com/jQuery/

I am now trying to make that one work for me. Basically I need to display a dynamic binary tree. To show an MLM genealogy tree.

Thanx

Member Avatar

diafol

OK. I don't have such a solution, sorry.

here is the simple code

<?php
$queue=array();
$queue[]=$_SESSION["details"]["id"];
echo "<center>".$_SESSION["details"]["id"]."</center>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style2 {color: #FF0000}
.style3 {color: #006600}
-->
</style>
</head>

<body>



<table width="254" border="1" align="center">

    
	
	
	<?php 
	$i=1;
$j=1;
do{
	if($i==$j*2){
		echo "<br><br><br><center>";
		$j=$j*2;
		}
	elseif($i==1){
		echo "<center>";
		}
$queue=array_values($queue);
$current=$queue[0];
unset($queue[0]);
	if($current!=0){
		$sel=mysql_query("select lchild,rchild from mlm_tree where userid='$current'");
		$row=mysql_fetch_array($sel);
     	if($row["lchild"]==0){
	 		echo '<b>&nbsp;&nbsp;&nbsp;&nbsp; <span class="style2">L</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
	 		}
   		else{
    		echo '<b>&nbsp;&nbsp;&nbsp;&nbsp;<span class="style3">'.$row["lchild"]."</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
			} 
		$queue[]=$row["lchild"]; 
		if($row["rchild"]==0){
	 		echo '<b>&nbsp;&nbsp;&nbsp;&nbsp; <span class="style2">R</span>&nbsp;&nbsp; &nbsp;&nbsp;';
	 
	 		}
   		else{
			echo '&nbsp;&nbsp;&nbsp;&nbsp;<span class="style3">'.$row["rchild"]."</span>&nbsp;&nbsp;&nbsp&nbsp;<b>"; 
			}  
		$queue[]=$row["rchild"];
	}else{
 
 		//echo "&nbsp;&nbsp;.&nbsp;&nbsp;";
		}
$i++;
  }while(count($queue)!=0 || $row["lchild"] != 0 || $row["rchild"]!= 0);
 
 	if($i==$j*2){
		echo " </center>";
		$j=$j*2;
			}
elseif($i==1){
echo "</center>";
}
 
 
  ?>

	
	
	
	
	
	
	

 
</table>


</body>
</html>

hallo there guys
i tried to make the example above work but is really complicated with my ldap search ....

has anyone got any news about the http://frank-mich.com/jQuery/

or any other way that is easy to adjust or modify to our ldap ...

thanks..

Member Avatar

diafol

How do you want your ldap search to conform to the binary tree model? Can't you loop through the nodes to get the info to store into the bintree?
Will the ldap data be binary??