时间:2021-07-01 10:21:17 帮助过:3人阅读
function getCat($pid,$lnum=1,$str='',$level=0){
static $catlist=array();
$sql= "select * categoryTable where pid=$pid";
$rst = mysql_query($sql);
while($row=mysql_fetch_assoc($rst)){
$l = str_repeat("   ",$level*$lnum);
$catname =$l.($pid==0?'':$str).$row['cat_name'];
$catlist[]=array('catid'=>$row['cat_id'],
'catname'=>$catname
);
getCat($row['cat_id'],$lnum,$str,$level+1);
}
return $catlist;
}