1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| <?php
$base_url = base_url();
$data = $rows->result();
// affichage
$col = -1;
$nbMax = 4;
$html = array();
if ( ! empty($data)) {
$html[] = '<tr>';
foreach($data as $item) {
if (++$col === $nbMax) {
$html[] = '</tr><tr>';
$col = 0;
}
$html[] = <<<HTML
<td>
<h6 align="center">{$item->id} :<br /></h6>
<a href="$base_url{$item->path}" rel="imagezoom[images]" title="{$item->comment}" />
<img src="$base_url{$item->path}" width="100" rel="imagezoom" /><br />
<!-- {$item->comment}<br /> -->
</td>
HTML;
}
// on complète avec des cellules vides si le nombre d'images
// n'est pas multiple du nombre d'images par ligne
while(++$col < $nbMax) {
$html[] = '<td> </td>';
}
$html[] = '</tr>';
}
?>
<table align="center">
<tbody>
<?php echo implode("\n", $html); ?>
</tbody>
</table> |