Re: Create a matrix gallery
| From: | Simon | Date: | Tue, 04 Sep 2007 13:28:33 +0000 |
| Subject: | Re: Create a matrix gallery | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-261683@lists.php.net to get a copy of this message | ||
> What I want to to do is insert a new <td> after showing 5 thumb images, and
> continue with the next picture on the next row.
> something like this
> __________________________
> |pic1 | pic2 | pic3 | pic4 | pic5 |
> __________________________
> |pic6 | pic7 | pic8 | pic9 | pic10 |
> __________________________
> |pic11 | pic12 | pic13 |
> __________________
You need to use the math function: modulo.
$MaxRows = 5;
for(.......){
$m = fmod($ImageNumber, $MaxRows);
if($m == 0){ echo "<tr>"; }
echo "<td>";
// [...] content of cell here
echo "</td>";
if($m == ($MaxRows-1)){ echo "</tr>"; }
}
Have fun!
Simon