I would like to surround this entire block of code in a try/catch since its causing an error when there is nothing in the grid array. Whats the best way to do this?
<?php foreach ($grid->result() as $idx => $row): ?> <?php if ($idx % 3 == 2): ?>
<div class="img_grid_3"><img src="/images/thumb/<?= $row->images_name; ?>" /></div>
<?php else: ?>
<div class="img_grid"><img src="/images/thumb/<?= $row->images_name; ?>" /></div>
<?php endif; ?>
<?php endforeach; ?>
Thanks
Maybe Im missing the point but why dont you test $grid before doing the foreach?