Home >Backend Development >PHP Tutorial >How to implement nested loops of data by category in Thinkphp, thinkphp nesting_PHP tutorial
The example in this article describes how to implement nested loops of data by category in Thinkphp. Share it with everyone for your reference. The specific implementation method is as follows:
When doing thinkphp, you need to use nested loops inside loops, and the second loop is related to the outside one.
The document given by thinkphp official website is:
The tables I want to use here are: classification table (Table 1), data table (Table 2)
The effect to be achieved is:
In fact, the principle is to first find the classification table (Table 1), then query Table 1 and Table 2, and finally output it in the form of a two-dimensional array
The background code is as follows:
I hope this article will be helpful to everyone’s ThinkPHP programming design.
{$sub}