Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi
I have a small problem.
I have an N level Category Table on Mysql : CatID | CatName | Parent
I would like to use a function (maybee recursive) to retreive all Sub and sub-sub.. categories from it starting from [b]SPECIFIC [/b]CatID
The Problem is that when i want to collect all the Subcategories ID's (and/Or SubCats Name) into an array and return it from the function , it doesnt work. But when printing the current leaf within the function it is working .
here is the code:(the function GetAllCategories(); retrieves a multi dimentional array with all categories)Code: Select all
function GetSubCats($parent) {
if (!$count) $count=0;
$CATS=GetAllCategories();
$categoryCount=count($CATS[CatID]);
for ($i=0; $i<$categoryCount; $i++) {
if ($CATS[Parent][$i] == $parent) {
$S[CatID].=$SUBS[CatName][$i]."|";
GetSubCats($CATS[CatID][$i]);
} //end if
} //end for
return $s;
}Please help ...
Thanks
moshe
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]