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