真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

目錄tree在頁面上顯示

//完整的目錄結(jié)構(gòu)
    function get_dir_tree($uid,$from_dir=0){
        $sql = "select dir_id,dir_name,depth,p_id from $this->_dir_table where user_id=$uid and is_del=0 and dir_id>=$from_dir";
        $res = $this->db->query($sql)->result_array();
        if(!isset($res[0])){
            return null;
        }
        $this->load->helper('array');
        //獲取depth區(qū)間
        $max_depth = 0;
        foreach($res as $dps => $d){
            if($d['depth']>$max_depth){
                $max_depth = $d['depth'];
            }
        }
        for($i=$max_depth;$i>=0;$i--){ //處理成樹形,子集存在child里,有沒有自己看有沒有child字段
            foreach($res as $key=>$val){
                if($val['depth']==$i){
                    foreach($res as $k=>$v){
                        if($val['p_id']==$v['dir_id']){
                            $v['child'][] = $val;
                            $res[$k] = $v;
                            unset($res[$key]);
                        }
                    }
                }
            }
        }
        $return =  $this->has_child_then_add_ul($res);
        $html="";
        return $html;
    }
    private function has_child_then_add_ul($res,$html='',$collaps_times=1){
        $collaps = 15;//前端寫的是m_l_15, m_l_30 這樣的 , 15為一個單位,跟前端商定就好
        $indent = $collaps_times*$collaps;
        $has_sibling = 0;
        $ul_begin = "
    "; $ul_end = "
"; $li_begin = "
  • ";//%s處是dir_name // $li_begin = "
  • %s";//%s處是dir_name $li_end = "
  • "; $count_li_end = $count_ul_end = 0; foreach($res as $key=>$val){ if(0==$key){ $html.=$ul_begin; } $html.=sprintf($li_begin,$indent,$val['dir_name']); $count_li_end++; if(isset($val['child'])){ $html = $this->has_child_then_add_ul($val['child'],$html,$collaps_times+1); } $html.=$li_end; if(!isset($res[$key+1])){ $html.=$ul_end; } } return $html ; }

    當(dāng)前標(biāo)題:目錄tree在頁面上顯示
    網(wǎng)頁鏈接:http://weahome.cn/article/pssooh.html

    其他資訊

    在線咨詢

    微信咨詢

    電話咨詢

    028-86922220(工作日)

    18980820575(7×24)

    提交需求

    返回頂部