版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36020968/article/details/85088278
tp3中一个二维数组和多个二维数组在视图层的渲染
$list = $packageGoods->limit($Page->firstRow.','.$Page->listRows)->where($where)->select();
$arr = array_map('reset',$list);
foreach($arr as $arr2) {
$m = M('kb_package');
$sql="select state,count(state) as count from kb_package WHERE package_goods_id = '$arr2' group by state";
//$sql = "SELECT kb_package.state,kb_package.brand_id,count(state)AS count FROM kb_package LEFT OUTER JOIN kb_package_goods ON kb_package.package_goods_id = kb_package_goods.id WHERE package_goods_id = '$arr2' GROUP BY state";
$data[] = $m->query($sql);
}
$this->assign('data',$data);// 赋值数据集
$this->assign('list',$list);// 赋值数据集
输出数据集多个数组 list
<table class="table table-hover table-bordered">
<thead>
<tr>
<th class="text-center">商品前缀</th>
<th class="text-center">商品名称</th>
<th class="text-center">面额</th>
<th class="text-center">预警阈值</th>
<th class="text-center">是否为采购商品</th>
</tr>
</thead>
<tbody>
<volist name='list' id='user'>
<tr>
<td style="height:40px">{$user.prefix}</td>
<td style="height:40px">{$user.name}</td>
<td style="height:40px">{$user.price}</td>
<td style="height:40px">{$user.warning_num}</td>
<td style="height:40px">
<switch name="user.is_purchase">
<case value="0">否</case>
<case value="1">是</case>
<default />未知数据
</switch>
</td>
</tr>
</volist>
</tbody>
</table>
<table class="table table-hover table-bordered">
<thead>
<tr>
<th class="text-center">状态统计</th>
</tr>
</thead>
<tbody>
<volist name="data" id="vo">
<tr >
<td style="height:40px">
<volist name="vo" id="f" empty="无数据">
<switch name="f.state">
<case value="0">未分配</case>
<case value="1">已分配</case>
<case value="2">已激活</case>
<case value="3">导出中</case>
<case value="4">已导出</case>
<case value="5">导入错误软删除</case>
<case value="6">误发数据</case>
<case value="8">过期数据</case>
<default />未知数据
</switch>
{$f['count']}
</volist>
</td>
</tr>
</volist>
</tbody>
</table>
图片中统计状态为多个数组,前边为一个数组,
分别对应的数组为
数组
list