gpt4 book ai didi

php - 限制每行表格单元格的数量

转载 作者:行者123 更新时间:2023-11-30 00:05:53 25 4
gpt4 key购买 nike

您好,我已经创建了一个分页脚本,但打印时遇到问题..我想在新行中打印每 3 条记录,这是我的 while 循环。

echo '<table cellspacing="12px" id="table">';
echo '<tr>';
while($row = mysqli_fetch_array($results))
{

echo ' <td><div class="data1r1"><span class="datamore">'.$row['title'].'</span></div></td>';
}
echo '</tr>';

echo '</table>';

我猜测是否有任何想法在每打印 3 条记录后就换行。

最佳答案

有一个计数器($brk_cnt)来计算3的倍数,然后:

$brk_cnt = 0;

while($row = mysqli_fetch_array($results))
{
echo ' <td>
<div class="data1r1"><span class="datamore">'.$row['title'].'</span></div>
</td>';

//break or print <tr> condition
if(++$brk_cnt % 3 == 0)
{
echo '</tr><tr>';
}
}

关于php - 限制每行表格单元格的数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24551791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com