ThinkPHP double loop traversal output
Data table 1 Cat column
Data table 2 In article
$cat= D("Cat"); $in = D("In");$total = $cat -> select();foreach($total as $k => $v){ $total[$k]['new'] =$in -> where(array('cat_title' => $v['cat_title'])) -> limit(10) -> select(); }$this -> assign('total',$total);
view page
<volist name="total" id="v"> <dl class="noMr"> <dt class="comBg senseTle"> <a href="__APP__/part/{$v.cat_id}/" title="{$v.cat_title}" target="_blank">{$v.cat_title}</a> </dt> <volist name="v['new']" id="vo"> <dd> <a class="txtellipsis" href="__APP__/spart/{$vo.in_id}.html" target="_blank" title="{$vo.in_title}">{$vo.in_title}</a> <span>{$vo.in_tm}</span> </dd> </volist> </dl> </volist>
This article explains the relevant content of ThinkPHP double loop traversal output. For more related content, please pay attention to the PHP Chinese website.
Related recommendations:
Introduction to the quick start method of ThinkPHP5
Introduction to the steps to use ThinkPHP
The above is the detailed content of ThinkPHP double loop traversal output related content. For more information, please follow other related articles on the PHP Chinese website!