<?php header("Content-Type:text/html;charset=utf-8"); include('./db.inc.php'); function cateList($pid=0,&$result=array(),$spac=0){ $spac+=2; $sql="SELECT * FROM cate WHERE pid=$pid"; $res=mysql_query($sql); while($row=mysql_fetch_assoc($res)){ $row['catename']=str_repeat(' ', $spac).'|--'.$row['catename']; $result[]=$row; cateList($row['id'],$result,$spac); } return $result; } function displayCate($pid=0,$select=1){ $rs=cateList($pid); $str=''; $str.= "<select name='cate'>"; foreach ($rs as $k => $v) { $selectstr=''; if($v['id']==$select){ $selectstr="selected"; } $str.= "<option {$selectstr}>{$v['catename']}</option>"; } return $str.= "</select>"; } echo displayCate(0,5); ?>
noprom
2014-09-30
0 回答
举报
0/150
提交
取消