Hi! I'm currently working on a small photo-sharing website that allows user uploads,etc. My problem resides in designing a neat layout to display the thumbnails of the photos that have been uploaded by a particular use.

In the current system, they are displayed in different rows by using the <tr><td></td></tr>, with the photos in the cells. I would like to display them as follows:

Photo1 | Photo2 | Photo3 | Photo4
Photo5 | Photo6|

The above is for a situation where there a 6 photos and in general, I want it to be a n*4 layout where the number of columns is constant i.e. 4. Hence, if I have 2 photos, it would be as follows:

Photo1 | Photo2

How do I go about coding the above?

PS: To start, I can put 2 for loops, but where do I check for the number of photos,etc..?