$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 ();}
Probably means there are two tables, type tables and goods tables, 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.
What I want to do now is to loop out the categories in the Type table and then loop the contents of the corresponding goods table under each category.
But I didn't use thankphp before, I don't know how to write it. The top one must be wrong, I just write what I mean.
Ask the great God to write a demo I see, thank you.
Reply to discussion (solution)
$result =m (' goods ')->join (' Right join goods on goods.pid = Type.id ')->select ();
foreach ($result as $key = = $v) {
$value [$v [' pid ']][$key] [' Goodsname ']= $v [' Goodsname '];
.. goods to fetch the content
}
The page shows the words with two volist loops can be done
$type _list = M ("type")->where ()->order ()->limit ()->select (); foreach ($type _list as $key = + $val) { $type _list[' items '] = M ("Goods")->where ("pid={$val [' ID ']}")->select ();
Maybe that's what you want.