Hi!
I need help in viewing 5 images per page, this script shows all the images on one page, but I want to create automated "next" and "previous" links. It'd be great if anyone could give hand on this one, thanks.
<html>
<head>
</head>
<body>
<?
// Some configuration variables !
$maxWidth = 90;
$maxHeight = 90;
$maxCols = 8;
//view 5 img per page
$imgPerPage = 5;
$webDir = "http://localhost.com/images/";
$localDir = $_SERVER['DOCUMENT_ROOT']."images/";
$AutorisedImageType = array ("jpg", "jpeg", "gif", "png","bmp");
?>
<center>
<table border='1' cellspacing='5' cellpadding='5' style="border-collapse:collapse; border-style: dotted">
<tr>
<?
// Open localDir
$dh = opendir($localDir);
while (false !== ($filename = readdir($dh))) {
$filesArray[] = $filename;
}
// Display and resize
foreach ($filesArray as $images) {
$ext = substr($images, strpos($images, ".")+1, strlen($images));
if( in_array($ext, $AutorisedImageType) ) {
list($width, $height, $type, $attr) = @getimagesize( $localDir.$images );
$xRatio = $maxWidth / $width;
$yRatio = $maxHeight / $height;
if ( ($width <= $maxWidth) && ($height <= $maxHeight) ) {
$newWidth = $width;
$newHeight = $height;
}
else if (($xRatio * $height) < $maxHeight) {
$newHeight = ceil($xRatio * $height);
$newWidth = $maxWidth;
}
else {
$newWidth = ceil($yRatio * $width);
$newHeight = $maxHeight;
}
if($i == $maxCols) {
echo "</tr><tr>";
$i = 0;
}
echo "<td align='center' valign='middle' width='$maxWidth' height='$maxHeight'><img src='".$webDir.$images."' width='$newWidth' height='$newHeight'></td>";
$i++;
}
}
?>
</tr>
</table>
</center>
</body>
</html>