这就是我想要的,在表格中的一组说3行之后我插入一个空白行 这是我创建表格和填充数据的代码
$row_count =0;
while($data = $result->fetch_assoc()){
$row_count++;
$tbl .=' <tr>
<td>' .' ' .$data['houseNumber'].'</td>
<td>' .' '.$data['tenantName'].'</td>
<td>' .' '.$data['status'].'</td>
<td>' .' '.$data['rentDue'].'</td>
<td>' .' '.$data['rentPaid'].'</td>
<td></td>
<td></td>
<td></td>
<td>'.' ' .($data['rentPaid']).'</td>
</tr> ';
}//end while
我如何使用此$row_count
变量来执行此操作。
提前致谢
答案 0 :(得分:1)
您可以尝试:
$row_count =0;
while($data = $result->fetch_assoc()) {
$row_count++;
$tbl .=' <tr>
<td>' .' ' .$data['houseNumber'].'</td>
<td>' .' '.$data['tenantName'].'</td>
<td>' .' '.$data['status'].'</td>
<td>' .' '.$data['rentDue'].'</td>
<td>' .' '.$data['rentPaid'].'</td>
<td></td>
<td></td>
<td></td>
<td>'.' ' .($data['rentPaid']).'</td>
</tr> ';
if ($row_count % 3 == 0) {
//if is divisible for 3, put the blanck row
$tbl .=' <tr>
<td colspan="9"> </td>
</tr> ';
}
}
//end while