日期:2014-05-17 浏览次数:20444 次
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;
}