How to write a double loop in thankphp

Source: Internet
Author: User
How to write $ left_type & nbsp ;=& nbsp; M ('type')-& gt; where ("'pid '= '2'")-& gt; order (''order' & nbsp; desc, 'id' & nbsp; desc ')-& gt; limit ()-& gt; select (); how to Write double loops in thankphp
$left_type = M('type')->where("`pid`='2'")->order('`order` desc,`id` desc')->limit(0,10)->select();

foreach($left_type as $v){
    $left_goods = M('goods')->where("`pid`='$v[id]'")->order('`order` desc,`id` desc')->limit(0,10)->select();
}


Generally, there are two tables: the type table and the goods table. the type table is the parent table of the goods table, and the id field in the type table corresponds to the pid field in the goods table.
Now I want to implement a loop of classes in the type table first, and then the corresponding content in the goods table under each category.
However, thankphp has never been used before and I don't know how to write it. The top one must be wrong. I mean, I mean.

Please read the demo by hand. thank you. Share: More

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.