thinkphp data nesting loops, thinkphp nested loops
When doing thinkphp, it is necessary to use loops inside the loop, and the second loop is associated with the outside.
The documents given by the thinkphp website are:
"
list
" id=
"
vo
">
"
vo[' Sub ']
" id=
"
Sub
">
{$sub. Name}
The table I want to use is: Classification table (table 1), Data Sheet (table 2)
The effect to be achieved is:
<表1_1>
<表2_1>
<表2_2>
<表1_2>
<表2_3>
<表2_4>
In fact, the principle is to find out the classification table (table 1), and then the table 1 and table 2 are related to the query, and finally a two-dimensional array output
Background code:
$m =m (' table 1'); $m 1=m (' table 2'); $parent=Select($m ); foreach as $n = $val) { $parent [$n] ['voo']= $m 1-> where(' table 2 and table 1 are associated with fields ='. $val [' table 1id']. Select(); $this->assign ('list', $parent); $this->display ();
The foreground output shows:
"
list
" id=
"
vo
">
{$vo. ID}
"
vo[' Voo '"
id=
"
Sub
">
{$sub. Title}
The effect is:
thinkphp Nested Loops
{$sub}
</volist>
</volist>
How to loop output in thinkphp?
You need to use the tag nesting, please refer to the ThinkPHP3.0 full development manual 8.21 tag nesting:
{$sub. Name}
</volist>
</volist>
http://www.bkjia.com/PHPjc/840768.html www.bkjia.com true http://www.bkjia.com/PHPjc/840768.html techarticle thinkphp data nesting loop, thinkphp nested loop to do thinkphp when the loop is nested loop inside, and the second loop is associated with the outside. Thinkphp's official website ...