Thinkphp nested loop implementation method, thinkphp nested _php tutorial

Source: Internet
Author: User

thinkphp the data in the nested Loop implementation method by classification, thinkphp nested


In this paper, the implementation method of nested loops of data in thinkphp is described. Share to everyone for your reference. The implementation method is as follows:

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:

Copy the Code code as follows:

{$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

The background code is as follows:

Copy the Code code as follows: $m =m (' table 1 ');
$m 1=m (' Table 2 ');

$parent = $m->select ();
foreach ($parent as $n = = $val) {
$parent [$n] [' Voo ']= $m 1->where (' Table 2 and table 1 associated fields = '. $val [' Table 1id ']. ') ->select ();
}
$this->assign (' list ', $parent);
$this->display ();
The foreground output shows:

Copy the Code code as follows:

  • {$vo. ID}


  • {$sub. Title}



  • The effect is as follows:

    It is hoped that this article is helpful to everyone's thinkphp program design.


    thinkphp Nested Loops



    {$sub}
    </volist>
    </volist>

    thinkphp How to nest Loops


    http://www.bkjia.com/PHPjc/903475.html www.bkjia.com true http://www.bkjia.com/PHPjc/903475.html techarticle thinkphp The data in the nested loop implementation method, thinkphp nested in this article describes the data in the thinkphp by the classification nested loop implementation method. Share to everyone for your reference. Concrete Reality ...

  • Related Article

    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.