: This article mainly introduces shopNC classification and hierarchical display of recursive queries. For more information about PHP tutorials, see. 1. prepaid:
2. Requirements: displays data hierarchically based on the classification table,
3. implement and paste the following code:
// Query the category list
$ Tmp_list = $ model_class-> getTreeClassList (3); // All lists if (is_array ($ tmp_list) {foreach ($ tmp_list as $ k => $ v) {$ num = $ model_class-> recursive ($ v ['tax _ parent_id ']); // The recursive query method $ tmp_list [$ k] ['tax _ name'] = str_repeat ("-", $ num) is required here ). $ v ['tax _ name'];}
// Recursive query
// @ Param int $ tax_parent_id parent ID
// @ Param int $ num
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 ;}
4. Complete
Copyright Statement: This article is the original author of the article, reproduced please notify the blogger mailbox: 519585292@qq.com.
The preceding section describes shopNC classification and recursive display at the query level, including some content. I hope my friends who are interested in PHP tutorials will be helpful.