ShopNC classification, recursive query hierarchical display

Source: Internet
Author: User
: 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.