shopNC classification, recursive query hierarchical display

WBOY
Release: 2016-08-08 09:19:31
Original
974 people have browsed it

1. Post the picture first:
shopNC classification, recursive query hierarchical display

2. Requirements are displayed hierarchically according to the classification table, as shown in the figure:
shopNC classification, recursive query hierarchical display

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>
Copy after login

/ /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>
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template