hi guys,
my head isn''t with it today and i'm working on a script which iterates through all the images in a folder and outputs the images in a table. I want to limit each iteration to 4 images i.e. I want to output the following..
<tr>
.... <td><img 1
.... <td><img 2
.... <td><img 3
.... <td><img 4
</tr>
<tr>
.... <td><img 5
.... <td><img 6
.... <td><img 7
.... <td><img 8
</tr>
How can I possibly iterate through the first 4 files, output a row end tag </tr> and a new row tag <tr> and then iterate through the next 4 etc.
The result is needed so that I can display the images (4 to a row in a gallery).
Sorry if this seems like a stupid request but I can't work it out!
edit:
This is the top of my code
Also if I could page the output based on the total number of images that would be very handy.
my head isn''t with it today and i'm working on a script which iterates through all the images in a folder and outputs the images in a table. I want to limit each iteration to 4 images i.e. I want to output the following..
<tr>
.... <td><img 1
.... <td><img 2
.... <td><img 3
.... <td><img 4
</tr>
<tr>
.... <td><img 5
.... <td><img 6
.... <td><img 7
.... <td><img 8
</tr>
How can I possibly iterate through the first 4 files, output a row end tag </tr> and a new row tag <tr> and then iterate through the next 4 etc.
The result is needed so that I can display the images (4 to a row in a gallery).
Sorry if this seems like a stupid request but I can't work it out!
edit:
This is the top of my code
Code:
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
Also if I could page the output based on the total number of images that would be very handy.
Last edited: