What is CI?
CodeIgniter is a lightweight but powerful PHP framework, based on the MVC design pattern, provides a rich class library, easy to learn, efficient and practical.
Below look at the CI frame infinite class + recursive implementation code, the specific code is as follows:
Stepless category + Recursive public function Digui () {$CRR = $this->db->get (' category ')->result_array (); $list [' type '] = $this-&
Gt;nolimit ($CRR, 0,0);
$this->load->view (' List1 ', $list); The Public Function Nolimit ($CRR, $p _id, $level) {Static $arr = array (); foreach ($CRR as $v) {if ($v [' parent_id ']== $p _id) {$v ['
Level '] = $level;
$arr [] = $v;
$this->nolimit ($CRR, $v [' cat_id '], $level + 1);
} return $arr; } <td><? PHP echo str_repeat (' ', $val [' Level '])? ><?php echo $val [' Cat_name ']?></td>/ Get Level 1, Level 2, 3 level public function Sel_child ($p _id) {$arr = $this->sel_son ($p _id); foreach ($arr as $k => $v) {$tmp = $this-&
Gt;sel_son ($v [' cat_id ']); foreach ($tmp as $kk => $vv) {$tmp 2 = $this->sel_son ($vv [' cat_id ']); $tmp [$kk] [' childs '] = $tmp 2; $arr [$k] [' child ']
= $tmp;
return $arr; ///Get all subordinate classification public function Sel_son ($id) {$this->db->where ("parent_id= $id") by ID; return $this->db->get (
Self:: $cate)->result_array (); //Render Presentation Home template public function Lists () {$p _id = 0; $brr [' type '] = $this->home_model->sel_child ($p _id); $brr [' list '] = $this->db->get ('
Goods ')->result_array ();
$this->load->view (' home/list.html ', $BRR); <?php foreach ($type as $v) {?> <li id= "cat_1" class= "" >
The above is a small series to introduce the CI framework of infinite Classification + recursive implementation code, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!