<?php
include 'connection.php';
$select_query = "select * from products";
$result = mysqli_query($conn, $select_query);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
$name = $row['name'];
$price = $row['price'];
$quantity = $row['quantity'];
$image = $row['image'];
echo "<section style='background-color: #eee;'>
<div class='container py-5'>
<div class='row'>
<div class='col-md-12 col-lg-4 mb-4 mb-lg-0'>
<div class='card'>
<div class='d-flex justify-content-between p-3'>
<p class='lead mb-0'>Today's Combo Offer</p>
<div class='bg-info rounded-circle d-flex align-items-center justify-content-center shadow-1-strong' style='width: 35px; height: 35px;'>
<p class='text-white mb-0 small'>x4</p>
</div>
</div>
<img src=$image class='card-img-top' />
<div class='card-body'>
<div class='d-flex justify-content-between mb-3'>
<h5 class='mb-0'>$name</h5>
<h5 class='text-dark mb-0'>$$price</h5>
</div>
<div class='d-flex justify-content-between mb-2'>
<p class='text-muted mb-0'>Available: <span class='fw-bold'>$quantity</span></p>
<div class='ms-auto text-warning'>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
<i class='fa fa-star'></i>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>";
}
} else {
echo "No products in the database";
}
?>
I fetch the data from the database and it will contain three products and i put this bootstrap template
to show products information but it does not show properly I think it will create new row for each entry
in the database but i want these products to show horizontally how can i do that?
I try to again copy and paste this whole template in the while loop but it print 1 entry 3 times