$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();}
$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要取的内容
}
页面显示的话用两个volist循环可以搞定
$type_list = M("Type")->where()->order()->limit()->select();foreach($type_list as $key=>$val){ $type_list['items'] = M("Goods")->where("pid={$val['id']}")->select();}
<ul><volist name="type_list" id="vo"> <li>{$vo.title} <ul> <volist name="vo.items" id="it"> <li>{$it.name}</li> </volist> </ul> </li></volist></ul>