> 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php