11-18-2009, 03:18 PM
|
#2 (permalink)
|
|
The Addict
Join Date: Aug 2008
Posts: 336
Thanks: 8
|
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:
<?phpfunction 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.
|
|
|
|