Im trying to make a webshop, but i have a grid system problem with PHP.
JavaScript
x
<section class="container" id="products">
<div class="row">
<?php while($row = $result->fetch()):?>
<div class="col">
<?php include 'WebShop/kategorien/card.php'?>
</div>
<?php endwhile;?>
</div>
</section>
It would be great, if the row could have only max 4 elements and then start a new line
Advertisement
Answer
How’s this:
JavaScript
<section class="container" id="products">
<div class="row">
<?php
$in_this_row = 0;
while($row = $result->fetch()):
?>
<div class="col">
<?php include 'WebShop/kategorien/card.php'?>
</div>
<?php
$in_this_row += 1;
if ($in_this_row == 4)
{
$in_this_row = 0;
?>
</div>
<div class="row">
<?php
}
endwhile;
?>
</div>
</section>