recursive function not returning anything..
| From: | nate at savingadvice dot com | Date: | Sun, 07 Nov 2004 18:56:56 +0000 |
| Subject: | recursive function not returning anything.. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-201439@lists.php.net to get a copy of this message | ||
function recursePathLookup($CatID, $Path = array()) {
//Get the catid for this subcat
$sql = "SELECT SubCategoryID, Name FROM categories WHERE CategoryID =
'".$CatID."'";
$query = mysql_query($sql);
if(mysql_num_rows($query) == 1) {
$data = mysql_fetch_array($query);
$Path[] = $data["Name"];
recursePathLookup($data["SubCategoryID"], $Path);
} else {
//print_r($Path);
return $Path;
}
}
print_r(recursePathLookup(2));
Any ideas why when I uncomment the //print_r($Path) inside the function it
prints the value fine, but when I try to return the value and print it
outside the function I get nothing?
Thanks,
Nate