Forum Moderators: coopster
// initialize counter
$count = 0;
// set directory name
$dir = "./eventpics";
echo "<table width = '400' cellspacing='0' padding='0' border='0'><tr><td>";
// open directory and parse file list
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
// iterate over file list
// print filenames
while (($filename = readdir($dh))!== false) {
if (($filename!= ".") && ($filename!= "..")) {
$pos = strstr($filename, 'Thumbs');
if ($pos == false) {
$count ++;
//Aspect ratio calculations
$max_width = 300; // maximum x aperture in pixels
$max_height = 220; // maximum y aperture in pixels
$size = GetImageSize($dir."/".$filename);
$width_ratio = ($size[0] / $max_width);
$height_ratio = ($size[1] / $max_height);
if($width_ratio >=$height_ratio) {
$ratio = $width_ratio;
}
else {
$ratio = $height_ratio;
}
$new_width = ($size[0] / $ratio);
$new_height = ($size[1] / $ratio);
if ($count == 21) {echo "</td></tr><tr><td>";} //new row for pictures
//Put in link
echo "    <font size='2'><a class='gallery' href=".'"javascript:showimageinframe('."'".$dir."/".$filename."','myiframe',".$new_width.",".$new_height.");".'">'.$count."</a></font> ";
}
}
}
// close directory
closedir($dh);
}
}
Ideally, what I want is to do away with the links and replace them with Previous, Next buttons/arrows and have some JavaScript loading the images into an iframe.
How would I go about using JavaScript to do the previous, next events. Can I pass it an array from PHP and each time the next button is clicked just rewrite the innerHTML of the click buttons with a value from the array?
Thanks.