码迷,mamicode.com
首页 > 其他好文 > 详细

全路径无限极

时间:2016-12-15 21:01:31      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:cti   order   技术   mysq   return   array   img   bsp   lod   

<?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 = index();
    echo "<select>";
    foreach ($data as $key => $val) {
        echo "<option>{$val[‘catename‘]}</option>";
    }
    echo "</select>";
?>

技术分享

全路径无限极

标签:cti   order   技术   mysq   return   array   img   bsp   lod   

原文地址:http://www.cnblogs.com/guishugan/p/6184588.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!