【发布时间】:2017-12-09 23:25:34
【问题描述】:
我已经为此阅读了大量不同的想法,但似乎无法让其中任何一个适用于我的代码。目前我的产品显示在单列中,但我希望它们显示在 3 或 4 列网格中。这是我到目前为止的代码,希望有人能看到我哪里出错了。
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) { ?>
<div class="container">
<div class="col-sm-4">
<?php echo $row["ID"] . " - " . $row["item"] . "<br>";?>
<img src="img/<?php echo $row["image"] ?>" style="width:150px;height:150px;"><br>
<?php echo $row["description"] . " - $" . $row["price"]; ?>
<form method="post" action="viewcart.php">
<input type="hidden" name="item" value="<?php echo $row["item"]?>" />
<input type="hidden" name="price" value="<?php echo $row["price"]?>" />
<button type="submit">Add To Cart</button>
</form>
</div>
</div>
【问题讨论】:
-
但容器在while循环之外
-
是的,为什么循环里面有容器?
-
必须在 while 循环之外
标签: php bootstrap-4