Organizing Loop Output Horizontally
Posted: Tue Jun 17, 2008 6:22 pm
Hi there,
I've been searching google for some time now, and I scanned through the tutorials looking for answers. I can't figure it out.
I have the following code:
It's for a simple image gallery which pulls images from a folder. It resizes the images for Thumbnails on one page, when that image is clicked it reformats the page to display the full size image.
The Loop displaying the thumbs only displays them vertically so I will eventually have a column of 100+ images.
Is there a way to get the code to do two things:
1) Sort the images into a table of 4 across at a time,so the first 4 are in the first row, the next 4 are in the the second row etc.
And
2) if it reaches 20 images in length it will add a "next" link to the next page of 20 images?
the second part is not as important right now but i think that the 4 across is needed soon.
Thankyou for your help.
I've been searching google for some time now, and I scanned through the tutorials looking for answers. I can't figure it out.
I have the following code:
Code: Select all
<?php
if (isset($_GET['image'])) {
echo "<a href=\"http://www.nnjoi.com/digital/websites.php\" onClick=\"history.go(-1)\">Back to gallery</a><hr />";
echo "<img src=\"../images/websites/image(" . $_GET['image'] . ").png\" width=\"400\" height=\"300\" alt=\"\"/>";
} else {
for($n = 1; $n<8; $n++) {
echo "<a href=\"websites.php?image=" . $n . "\"><img src=\"../images/websites/image(" . $n . ").png\" width=\"100\" height=\"75\" alt=\"\"/></a>";
echo "<br /><br />";
}
}
?>
The Loop displaying the thumbs only displays them vertically so I will eventually have a column of 100+ images.
Is there a way to get the code to do two things:
1) Sort the images into a table of 4 across at a time,so the first 4 are in the first row, the next 4 are in the the second row etc.
And
2) if it reaches 20 images in length it will add a "next" link to the next page of 20 images?
the second part is not as important right now but i think that the 4 across is needed soon.
Thankyou for your help.