Home >Backend Development >PHP Tutorial >shopNC classification, recursive query hierarchical display

shopNC classification, recursive query hierarchical display

WBOY
WBOYOriginal
2016-08-08 09:19:31998browse

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>

/ /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.

Statement:
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