I'v got this script to display all the pictures
in a directory, it works fine. The problem is
that I have too many of them to be show on one
page, so I like to add page support to the script
and number of pictures per page. and i don't know
how to go by doin this. can any help me whit this and show me how i can do it and can it be done whit this script please help
here the script
<?php
$thumb_width = 80;
$thumb_height = 60;
$col = 6;
function resizeImage($originalImage,$tWidth,$tHeight){
list($width, $height) = getimagesize($originalImage);
$xscale=$width/$tWidth;
$yscale=$height/$tHeight;
if ($yscale>$xscale){
$newwidth = round($width * (1/$yscale));
$newheight = round($height * (1/$yscale));
}
else {
$newwidth = round($width * (1/$xscale));
$newheight = round($height * (1/$xscale));
}
$imageResized = imagecreatetruecolor($newwidth, $newheight);
$imageTmp = imagecreatefromjpeg ($originalImage);
imagecopyresampled($imageResized, $imageTmp, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
return $imageResized;
}
function generateThumbnails(){
global $thumb_width,$thumb_height;
if ($handle = opendir(".")) {
while ($file = readdir($handle)) {
if (is_file($file)){
if (strpos($file,'_rg.jpg')){
$isThumb = true;
} else {
$isThumb = false;
}
if (!$isThumb) {
$dirName = substr($file,0,strpos($file,basename($file)));
if (strlen($dirName) < 1) $dirName = '.';
$fileName = basename($file);
$fileMain = substr($fileName,0,strrpos($fileName,'.'));
$extName = substr($fileName,strrpos($fileName,'.'),
strlen($fileName)-strrpos($fileName,'.'));
if (($extName == '.jpg') || ($extName == '.jpeg')){
$thmbFile = $dirName.'/'.$fileMain.'_rg.jpg';
if (!file_exists($thmbFile)){
imagejpeg(resizeImage($file,$thumb_width,$thumb_he ight),$thmbFile,80);
}
}
}
}
}
}
}
function getNormalImage($file){
$base = substr($file,0,strrpos($file,'_rg.jpg'));
if (file_exists($base.'.jpg')) return $base.'.jpg';
elseif (file_exists($base.'.jpeg')) return $base.'.jpeg';
else return "";
}
function displayPhotos(){
global $col;
generateThumbnails();
$act = 0;
if ($handle = opendir(".")) {
while ($file = readdir($handle)) {
if (is_file($file)){
if (strpos($file,'_rg.jpg')){
++$act;
if ($act > $col) {
echo '</tr><tr><td class="photo"><div class="thumbsBox"><a href="view.php?image='.getNormalImage($file).'"><i mg src="'.$file.'" alt="'.$file.'"/></a></td>';
$act = 1;
} else {
echo '<td class="photo"><div class="thumbsBox"><a href="view.php?image='.getNormalImage($file).'"><i mg src="'.$file.'" alt="'.$file.'"/></a></td>';
}
}
}
}
}
}
?>
<html>
<head>
<link rel="stylesheet" href="images/styles.css" type="text/css" media="screen">
</head>
<body>
<title>Photo Gallery</title>
<div>
<div id="pic" style="position:absolute; left:0px; top:0px;">
<img src="images/header1.jpg" border=0 width=780 height=100>
</div>
<div id="pic" style="position:absolute; left:0px; top:100px;">
<img src="images/counter.jpg" border=0 width=780 height=34></div>
<br><br><br><br><br><br><br><br><br><br><br>
<hr WIDTH="100%" SIZE="1">
<u><a href=" http://.com"title="Copyright 2006-2007Copyrights And Trademarks Are Property Of Their Respective Owners. All Rights Reserved."class="rgstyle"><font size=2 color="#FF0000">Copyright 2006-2007 RippedGames Inc.</a><div>All Other Copyrights And Trademarks Are Property Of Their Respective Owners. All Rights Reserved.</u></center>
</body>