需求
记录集参考文章
MYSQL|count()函数使用条件分别统计
代码
<table lay-filter="ftTb" class="layui-table">
<thead>
<tr>
<th>No</th>
<th>类别</th>
<th>类别明细</th>
<th>提交数</th>
<th>处理数</th>
<th>合格数</th>
<th>不合格数</th>
</tr>
</thead>
<tbody>
<?php
$prev=0;
?>
<volist name="list" id="vo">
<tr>
<?php
if($vo[class1_id]!=$prev){
$sql="
select count(*)
from `class2`
where class2_class1_id=$vo[class1_id]
";
$rowspan=current(M()->query($sql)[0]);
?>
<td rowspan="{$rowspan}">{$vo[class1_id]}</td>
<td rowspan="{$rowspan}">{$vo[class1_name]}</td>
<?php
}
?>
<td>{$vo[class2_name]}</td>
<td>{$vo[count_all]}</td>
<td>{$vo[count_done]}</td>
<td>{$vo[count1]}</td>
<td>{$vo[count2]}</td>
</tr>
<?php $prev=$vo[class1_id];?>
</volist>
</tbody>
</table>