首页 > 代码库 > 全路径无限极

全路径无限极

<?php
header("Content-type: text/html; charset=utf-8");
include(‘./db_mysql.php‘);
    /**全路径无限极
     * [index description]
     * @return [type] [description]
     */
    function index(){
        $sql = "SELECT id,catename,path,concat(path,‘,‘,id) as fullpath FROM recursions ORDER BY fullpath asc";
        $sq = mysql_query($sql);
        $arr = array();
        while ($sqls = mysql_fetch_assoc($sq)) {
            $dd = count(explode(‘,‘,trim($sqls[‘fullpath‘],‘,‘)) );
            $sqls[‘catename‘] = str_repeat(‘&nbsp;&nbsp;‘, $dd).‘|~~‘.$sqls[‘catename‘];
            $arr[] = $sqls;
        }
        return $arr;
    }
    $data = http://www.mamicode.com/index();
    echo "<select>";
    foreach ($data as $key => $val) {
        echo "<option>{$val[‘catename‘]}</option>";
    }
    echo "</select>";
?>

技术分享

全路径无限极