樹狀迴圈輸出,好幾天了也沒做好,請大神幫幫參考下

來源:互聯網
上載者:User
資料庫

怎麼輸出為這樣的
111111*121212*3232323222222222*333333**44444444***555555***werwerwer**6565656*23232323**324234234


sonclass 是包含的子類id 怎麼能樹狀迴圈出html這樣的效果? 我只會輸出一層 沒辦法向這樣有子分類就一直迴圈輸出出來


回複討論(解決方案)

你這裡不需要子id,有父id就行啦,你根據classid查詢子id就行了

有父id,featherclass=classid,就能到到classid的下級

你這是想做什嗎??

有父id,featherclass=classid,就能到到classid的下級


可以寫出具體點的嗎 感謝!!

$class  =  $this->tclass->get_all_class($this->tbname);        $json_class = Array();        $json_class2 = array();        foreach ($class as $key=>$value) {  if($class[$key]['sonclass']) //如果有子分類            {                $json_class[$key]['id'] = $value['classid'];                $json_class[$key]['text'] = $value['classname'];                $son_arr = $this->tclass->get_son_class($value['sonclass'],$this->tbname);                foreach ($son_arr as $k=>$v) {                   $json_class1[$k]['id'] = $v['classid'];                   $json_class1[$k]['text'] = $v['classname'];                      }               $json_class[$key]['children'] = $json_class1;            }        }


我這樣只能得出父和一層子 怎麼能迴圈得出子類?
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.