I have a while loop from database, but i want to wrap every 2 rows into a div.
Currently i have this but is only wrapping first row.
<?php
$get = $connect->query("SELECT * FROM sabiaque ORDER by ordem");
$num = 0;
while ($f = $get->fetch_array(MYSQLI_ASSOC)) {
if ($num % 2) {
echo '<div class="divisor-slide">';
}
echo'
<a href="'.$f['link'].'"><div class="item-a">
<div class="box1-item-a">
<div class="i-wrap"><h1 class="i-white">'.utf8_decode($f['titulo']).'</h1><p>'.utf8_decode($f['subtitulo']).'</p></div>
</div>
<div class="box1-item-b">
<img src="../'.$f['ficheiro'].'" style="max-width: 100%; height: 100%;" />
</div>
</div></a>
';
if($num % 2) {
echo '</div>';
}
$num++;
}
?>
if($num % 2)might be the culprit, tryif($num % 2 === 0), reason being that modulus returns the remainder, php loosly evaluates that remainder to true (if it's non zero)