View Single Post
Old 11-18-2009, 03:18 PM   #2 (permalink)
tony
The Addict
 
tony's Avatar
 
Join Date: Aug 2008
Posts: 336
Thanks: 8
tony is on a distinguished road
Default

the code looks like it does the job. But if you don't know how many levels of children there are I'll suggest to use a recursive function.

php Code:
<?php
function print_categories($aCat) {
    echo "<ul>\n";
    echo "\t<li>";
    if(is_array($row)) {
        print_categories($row);
    } else {
        echo '<a href="#">'.$aRow['name'].'</a>';
    }
    echo "\t</li>";
    echo "</ul>\n";
}

print_categories($aCategories);
?>

Although I haven't tested the this code, the idea is to make it recursive when the input is an array.
tony is offline  
Reply With Quote