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:
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..?
A long time ago I did something similar to this. It's very simple...Create a static variable for the number of columns you want. Then, you have another temporary incrementing variable telling you how many images you have outputted already. Once that variable is equal to the static variable, echo a new table row.
Now, you will need another if statement in that loop to make sure you don't echo a new table row if all the photos are used up as well.
Honestly, using a table is a poor implementation. You should just use <div> tags set to blocks with a set width and height.
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
Bookmarks