【发布时间】:2021-04-12 11:17:49
【问题描述】:
每次都创建新行,而不是创建四张卡片。我使用小 3 列,我想在一行中列出 4 张卡片,并像在电子商务网站中一样从数据库中获取数据
<div class="row container bg-light">
<?php
while ($result=mysqli_fetch_assoc($link)) {
echo "<a href='com.php?id=$result[id]' style='text-decoration:none;'>";
echo "<div class='col-sm-3 bg-white border rounded shadow'>";
echo "<div class='bg- m-2 text-center'>";
echo "<img src='adeolu-eletu-DXYyKCCvWiM-unsplash.jpg' alt='' class='w-75 h-75' >";
echo "<h3 class=''>$result[name]</h3>";
echo "<h6 class=''>$result[discription]</h6>";
echo "<h2 class='text-danger link'>Rs $result[price]</h2>";
echo "<Button class='btn bg-success '>Order</button>";
echo "<Button class='btn bg-danger '>Add to Cart</button>";
echo "</div>";
echo "</div>";
echo "</a>";
echo print_r($result);
}
?>
</div>
【问题讨论】:
-
您应该将锚点放在 DIV 中,而不是相反。
-
您应该提供minimal reproducible example。您对 HTML 和 CSS 有疑问。您包含了一堆没有帮助的 PHP,而不是指向 CSS 的链接。
-
echo print_r($result);应该是print_r($result);或echo print_r($result, true); -
这个锚点会影响创建新行的代码吗?
标签: php html twitter-bootstrap