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.