html - PHP col row grid system

Im trying to make a webshop, but i have a grid system problem with PHP.
<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
Answer
Solution:
How's this:
<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>
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: illuminate\http\exceptions\posttoolargeexception
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.