我有这个问题,我需要重复3次卡,但如果超过3次,则必须创建新的卡组,另外3个元素 帮助
<div id="service" class="text-center">
<br/>
<h2 class="display-1"><b title="Services provided by the site" class="initialism">Service</b></h2>
<br/>
</div>
<?php
if($stmt1->rowCount() > 0){
for($j=0;$row=$stmt1->fetch(PDO::FETCH_ASSOC);$j++){
?>
<div class="card-group">
<?php
for($i=0;$row=$stmt1->fetch(PDO::FETCH_ASSOC);$i++){
if ($i < 3){
?>
<div class="card">
<img class="card-img-top" src="style/img/homepage/homepageCardImageCap.svg" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
</div>
<?php }}?>
</div>
<?php }} ?>
答案 0 :(得分:0)
你必须为那个
嵌套for循环$count = 0;
for($j=0;$row=$stmt1->fetch(PDO::FETCH_ASSOC);$j++){
<div class="card-group">
for($count; $count == 3; $count++){
<div class="card">
<img class="card-img-top" src="style/img/homepage/homepageCardImageCap.svg" alt="Card image cap">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
</div>
</div>
}
$count = 0;
你现在得到的想法格式化代码。投票,如果这是有帮助的