hi list. I wonder if anyone can help me with this. i have a database with the file name of several images stored in a filesystem, and I want to create a table containing the image results of a query. this is my code <?php include_once("../../../connection/connection.php"); ?> <html> <head> <title>Image Gallery</title> </head> <table border=1> <?php //get the thumbsnails $getpic=mysql_query("select * from rsiis_images") or die(mysql_error()); while ($rows=mysql_fetch_assoc($getpic)) { extract ($rows); echo "<tr>"; echo "<td><a href=editing_image.php?pic=".$rows['image_id']."><img src=".$ImageThumb.$rows['image_id'].".jpg></td>"; } ?> </tr> </table> </body> </html> With this code, I am able to see the thumb images with their respective link ok, but if I have a query with 40 results, I will have a big row of images. ____________________________________________________ |pic1 | pic2 | pic3 | pic4 | pic5 | pic6 | pic7 | pic8 | pic9 | pic10 | ______________________________________________________ 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 | __________________ Thanks in advance. Yamil