我想在div后面加上br标记或hr标记,而我的div在while循环中。请检查下面的代码我做错了什么。
<?php $count =0;?>
<?php while($product = mysqli_fetch_assoc($featured)) : ?>
<?php $count++;
if($count%4 == 0) {
?><br><hr><?php
}
?>
<!-- Number 1 -->
<div class="col-md-3">
<h6><?= $product['title']; ?></h6>
<div class="container-fluid">
<div class="row" style="width:200px;height:200px">
<img src="<?= $product['image']; ?>" alt="<?= $product['title']; ?>" class="img-thumb" />
</div>
</div>
<hr>
<p class="list-price text-danger">List Price: <s>$<?= $product['list_price']; ?></s></p>
<p class="price">Our Price: $<?= $product['price']; ?></p>
<button type="button" class="btn btn-sm btn-success" onclick = "detailsmodal(<?= $product['id']; ?>)">Deatils</button>
</div>
在这里,我想给br标签后,4个产品显示在一个div,现在我的第五个产品显示后的详细信息按钮。我想在每个第5个产品上的详细信息按钮和标题之间留出空格,或者当我的div显示在另一行时。
<?php endwhile; ?>
欢迎您的建议。
发布于 2018-08-09 01:56:33
将conditional放在product div之后,将$count
放在conditional之后,如下所示:
<?php
$count = 1;
while($count <= 20) {
echo "Product ID: $count <br>";
if($count%4 == 0) echo "<hr>";
$count++;
}
https://stackoverflow.com/questions/51752548
复制相似问题