hi,
I want to list all the category and thier childrens recursively. But it's not working...
childrens are ignoring.
$cat=cat('21');
print_r($cat);
function cat($catid){
global $db,$prefix;
$id=array();
$result=$db->query("SELECT * FROM {$prefix}_client_cat WHERE cat_parent=$catid");
while($row=$db->fetch_array($result)){
if(haschild($row[cat_id])){
$idx[]=$row[cat_id];
cat($row[cat_id]);
$id=array_merge($idx,$id);
}else{
$id[]=$row[cat_id];
}
}
return $id;
}
function haschild($catid){
global $db,$prefix;
$result=$db->query("SELECT * FROM {$prefix}_client_cat WHERE cat_parent=$catid");
if($db->num_rows($result)>0){
return true;
}else{
return false;
}
}