function drawChartDownline($listOfItems) { echo "<ul>"; foreach ($listOfItems as $item) { echo "<li> \n <a href='" . base_url() . "profile/" . $item->attributes('username') . "'>" . $item->profile('nama') . "</a>"; if ($item->hasDownline()) { drawChartDownline($item->getDownline()); // here is the recursion } echo "</li>"; } echo "</ul>"; }
function drawChartDownline($listOfItems) { echo "<ul>"; foreach ($listOfItems as $item) { $merah = $item->attributes('status') != 1 ? "style='background:#FF9999'" : ''; echo "<li {$merah}> " . $item->profile('nama') . " (" . $item->attributes('username') . ")"; if ($item->hasDownline(false)) { drawChartDownline($item->getDownline(false)); // here is the recursion } echo "</li>"; } echo "</ul>"; }