I have a tree like
and I want the output for requeted ID for example Admin
I have a method that returns Child count level wise but I also want to return the child list level-wise with child count level-wise like 2nd image output required.
function childCountLevelWise($conn,$ID, $level){
if ($level>14){
$count = array(0=>0);
return $count;
}
$sql="select * from user_my_tree t where t.parent_ID=".$ID;
$result=returnResults($conn,$sql);
if ($result==null){
$count = array(0=>0);
}
else{
$count = array(0=>0);
foreach($result as $key=>$row)
{
$count[0]++;
$children=childCountLevelWise($conn,$row['ID'], $level+1);
$index=1;
foreach ($children as $child)
{
if ($child==0)
continue;
if (isset($count[$index]))
$count[$index] += $child;
else
$count[$index] = $child;
$index++;
}
}
}
return $count;
}