Posted by ghghj on 08/29/05 07:06
Please help. The script below displays photos from three folders in a
horizontal format. What I need the script to do is display the images in
vertical format. For example Folder one contains images1 and 2. Folder three
contains images 3 and 4 and folder3 contains images 5 and 6. Now the images
should appear as follows.
Column1 Column2 Column3
-----------------------------------
Image1 Image3 Image 5
Image2 Image4 Image 6
Thanks for the help.
<?php
$images1 = "image_gallery/column1/"; # Location of small versions
$big = "big/"; # Location of big versions (assumed to be a subdir of
above)
$cols = 3; # Number of columns to display
if ($handle = opendir($images1)) {
while (false !== ($file1 = readdir($handle))) {
if ($file1 != "." && $file1 != ".." && $file1 != rtrim($big,"/")) {
$files1[] = $file1;
}
}
closedir($handle);
}
$colCtr = 0;
echo '<table width="100%" cellspacing="3"><tr>';
foreach($files1 as $file1)
{
if($colCtr %$cols == 0)
echo '</tr><tr><td colspan="2"><hr /></td></tr><tr>';
echo '<td align="center"><a href="' . $images1 . $big . $file1 . '"><img
src="' . $images1 . $file1 . '" /></a></td>';
$colCtr++;
}
$images2 = "image_gallery/column2/"; # Location of small versions
$big = "big/"; # Location of big versions (assumed to be a subdir of
above)
$cols = 3; # Number of columns to display
if ($handle = opendir($images2)) {
while (false !== ($file2 = readdir($handle))) {
if ($file2 != "." && $file2 != ".." && $file2 != rtrim($big,"/")) {
$files2[] = $file2;
}
}
closedir($handle);
}
$colCtr = 0;
echo '<table width="100%" cellspacing="3"><tr>';
foreach($files2 as $file2)
{
if($colCtr %$cols == 0)
echo '</tr><tr><td colspan="2"><hr /></td></tr><tr>';
echo '<td align="center"><a href="' . $images2 . $big . $file2 . '"><img
src="' . $images2 . $file2 . '" /></a></td>';
$colCtr++;
}
$images3 = "image_gallery/column3/"; # Location of small versions
$big = "big/"; # Location of big versions (assumed to be a subdir of
above)
$cols = 3; # Number of columns to display
if ($handle = opendir($images3)) {
while (false !== ($file3 = readdir($handle))) {
if ($file3 != "." && $file3 != ".." && $file3 != rtrim($big,"/")) {
$files3[] = $file3;
}
}
closedir($handle);
}
$colCtr = 0;
echo '<table width="100%" cellspacing="3"><tr>';
foreach($files3 as $file3)
{
if($colCtr %$cols == 0)
echo '</tr><tr><td colspan="2"><hr /></td></tr><tr>';
echo '<td align="center"><a href="' . $images3 . $big . $file3 . '"><img
src="' . $images3 . $file3 . '" /></a></td>';
$colCtr++;
}
echo '</table>' . "\r\n";
?>
Navigation:
[Reply to this message]
|