Find ThinkPHP loop nesting and print out the list of parent classes and child classes. solution:

Source: Internet
Author: User
Calculate the ThinkPHP nested loop by 40 minutes to print out the list of parent classes and child classes. Hello, I have been learning the thinkPHP framework recently. I want to print out a data list cyclically on the template page, the format is: first, the parent class category name, then print the corresponding subclass list, then print another parent class name, and then print the corresponding subclass of the parent class, and so on... I used table formatting to print out the list of parent classes and child classes by using ThinkPHP loop nesting at 40 points.
Hello everyone, I have been studying the thinkPHP framework recently. I want to print out a data list cyclically on the template page. the format is: first, the parent category name, then print out the corresponding subclass list, then print another parent class name, then print the corresponding subclass of the parent class, and so on... I use table layout. the format is as follows:


Category name overview

Parent class name 1......
Subclass name 1 .....
Subclass name 2 .....
Subclass name 3 .....
Parent class name 2......
Subclass name 1 .....
Subclass name 2 .....
Subclass name 3 .....


Could you tell me how to implement it with volist, or is there any better way? thank you !!



------ Solution --------------------
You can use the return Field for traversal.

------ Solution --------------------
You can try it: for the first time, I will find all parent_id and write down the total parent_count of the record set. then I will loop down with parent_count, and so on ......
------ Solution --------------------
HTML code
            
                                      {$ Vo. depa_id}                    
   [Homepage]';?> {$ Vo. depa_title}                    {$ Vo. label_count}                    {$ Vo. model_name}                    {$ Vo. depa_order}                                
                                               {$ Son. depa_id}                        {$ Son. depa_title}                        {$ Son. label_count}                        {$ Son. model_name}                        {$ Son. depa_order}                                    
               
              
------ Solution --------------------


It is not easy to recursion in the template. the better way is to recursion the approximate tree structure in the program logic, and control the style in the template.
------ Solution --------------------
Associate model
PHP code
      {$ Vo. typeName}{$ Vo. typeDescription}  
           {$ Value. typeName}{$ Value. typeDescription}  
     
    
------ Solution --------------------
This is generally done with MYSQL. it is usually set in the database. first, set the same field VAL for the parent class and subclass, and then add a field for saving the parent class ID, then the WEB page can be recycled.

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.