1. Post the picture first:
2. Requirements are displayed hierarchically according to the classification table, as shown in the figure:
3. Implementation, the pasting code is as follows:
//Classification list query
<code>$tmp_list = $model_class->getTreeClassList(3);//所有列表 if (is_array($tmp_list)){ foreach ($tmp_list as $k => $v){ $num = $model_class->recursive($v['tax_parent_id']);//此处需要用到递归查询方法 $tmp_list[$k]['tax_name'] = str_repeat(" —",$num).$v['tax_name']; } } </code>
/ /recursive query
//@param int $tax_parent_id Parent ID
//@param int $num
<code>public function recursive($tax_parent_id, $num = 0){ $parent = $this->getGoodsClassinfo(array('tax_id'=>$tax_parent_id,'tax_parent_id')); if($parent == true){ $num++; $num = $this->digui($parent['tax_parent_id'],$num); } return $num; } </code>
4. Complete
Copyright statement: This article is an original article by the blogger. For reprinting, please notify the blogger's email: 519585292@qq. com.
The above introduces the shopNC classification, recursive query hierarchical display, including aspects of the content, I hope it will be helpful to friends who are interested in PHP tutorials.