标签:inf key ret info row function 列表 取数 select
最终效果图:
代码详情:
include(‘db.inc.php‘); function likecate($path=‘‘){ sql = "select id,catename,path,concat(path,‘,‘,id) as fullpath from likecate order by fullpath asc"; $res = mysql_query($sql); $result = array(); while($row = mysql_fetch_assoc($res)){ $deep = count(explode(‘,‘,trim($row[‘fullpath‘],‘,‘))); //取数组的深度,去除逗号 $row[‘catename‘] = str_repeat(‘ ‘,$deep).‘|--‘.$row[‘catename‘]; $result[] = $row; } return $result; } $res = likecate(); echo "<select name= cate>"; foreach ($res as $key => $value) { echo "<option> {$value[‘catename‘]}</option>"; } echo "</select>"; print_r($res);
标签:inf key ret info row function 列表 取数 select
原文地址:https://www.cnblogs.com/yangzailu/p/9675839.html