<div class="container">
<?php $i = 0; ?>
<?php foreach ($data as $row): ?>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3">
<div class="game-element">
<img src="<?=$row['POSTER']?>"><br>
<a href="?id=<?=$row['ID']?>" class="game-title"><?=$row['TITLE']?></a>
</div>
</div><!--game-element -->
<?php
$i++
if ($i == 4) {
$i = 0;
echo '</div><div class="container">';
}
?>
<?php endforeach ?>
<div>