I'm retrieving my items from Exact and displaying them usuing a PHP loop. However, i want to put a HTML tag (br) after every 3 items.
Is there a possibility to do this? My current code:
<?php
$glas = getGLAccounts($search);
$count = 0
foreach($glas as $gla) {
$count++;
echo "<tr><td><a href='glaccountedit.php?glaccount=".$gla['ID']."'>".$gla['Code']." </a></td><td> ".$gla['Description']."</td></tr>";
if ($count == 3) {
echo "</br>";
}
}
?>
However, this isn't working. What am I doing wrong?
if($count % 3 == 0)Use the modulo operator.if ($count == 3) {add$count = 0. But I think @nicovank solution is way better.