I am developing an e-commerce website using php. There I want to display 3 products per row (I have 6 of them) using php foreach
. Here is my code:
<div class="section">
<div class="container">
<?php
$numOfCols = 4;
$rowCount = 0;
$bootstrapColWidth = 12 / $numOfCols;
?>
<div class="row">
<?php foreach ($results as $product) { ?>
<div class="col-md-<?php echo $bootstrapColWidth;?>">
<div class="well" style="width: 250px;height: auto;">
<div><?php echo'<img src="' . base_url().'uploads/' . $product-
>product_image . '">'; ?></div>
<?php echo $product->name;?>
</div>
</div>
<?php
$rowCount++;
if($rowCount % $numOfCols == 0) {echo '</div><div
class="row">'.'<br>'.'<br>';
}
?>
<?php };?>
</div>
</div>
This code makes it show all products in a single column. I don't know how to make it show this in 2 columns instead.