<?php
$id='1';
$result=Myfunction($id);
function display($arr)
{
$markup='';
foreach ($arr as $key => $value) {
if($value!=0)
{
$markup.= '
'.((is_array($value))?display($value) : $value) .'';
}
else
{
$markup.='
empty';
}
}
return "<row>
";
}
function Myfunction($id)
{
$sql="SELECT * FROM `tbl_mlm` WHERE `id`='$id'";
$res=DBExecute($sql,"select");
if($res)
{
$set=$res[0];
$left=$set['left'];
$right=$set['right'];
$name=$set['name_tree'];
}
else
{
$left=0;
$right=0;
$name="not";
}
if($left!="0" AND $right!="0" )
{
$temp[$name."_left"]=$left;
$left_arr=Myfunction($left);
array_push($temp,Myfunction($left));
$temp[$name."_right"]=$right;
$right_arr=Myfunction($right);
array_push($temp,Myfunction($right));
}
else
{
$temp[$name."_left"]="0";
$temp[$name."_right"]="0";
}
return $temp;
}
?>