Ok I've checked on both the site and forum here for help on this but since I don't know exactly what the help is I'm looking for, I didn't really know where to look for it. Ok, here's the low-down, I've been working on an image database of sorts (to be used for free avatars, signatures, and later a simple screenshot gallery) using SQL for my site. Now, that works fine, but I'm getting the script to insert each image (avatars at the moment) into seperate cells in the table, and it causes the page to stretch nastilly once there's more than 5 cells side by side. What I need is a way to tell the script to automatically add "</tr><tr>" after every 5th entry into the table. Here's the script as it looks (so that it makes more sense, and yes I know the code is slightly messy, but meh, I'm not bothered about coding aesthetics at the moment): [code]echo " <table width=\"100%\" cellpadding=\"0\" cellspacing=\"1\"> <tr>"; while ($row=mysql_fetch_array($result)) { $id=$row["id"]; $name=$row["name"]; $artist=$row["artist"]; $artisturl=$row["artisturl"]; $series=$row["series"]; $category=$row["category"]; $date=$row["date"]; $previewimage=$row["previewimage"]; $download=$row["download"]; $viewhtml=$row["viewhtml"]; echo " <td width=\"100px\"><center><img src=\"$previewimage\" border=\"1px solid #000000\"><br>by $artist</center></td>"; } echo " </tr></table> <br><br> <center>";[/code] And here's the code in action - http://www.ffinsight.com/index.php?icon=10 Now I know I could switch the $row variable to be 5, but that means I could only display 5 avatars per page, and I want to display 25, and the page only looks right if I have 5 avatars lined next to each other. Any help on this would be greatly appreciated.