Well, you could read all the file names into an array first, slice the array, and then run your code on the new array, like so:
$limit = 30;
$page = (@$_GET['page'] ? $_GET['page'] : 1);
$file_list = array();
$handle=opendir($fulldir);
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "index.php" && $file != "Redundant" && $file != "images" && $file != "gallery.css" && $file != "webfxlayout.local.js" && $file != "Thumbs.db" && $file != "Mavica.htm" && $file != "blank.gif" && $file != "pngbehavior.htc") {
$file_list[] = $file;
}
}
$num_pages = ceil(count($file_list) / $limit);
$file_list = array_slice($file_list, ($limit * ($page - 1)), (($limit * ($page - 1)) + $limit));
foreach($file_list as $file) {
$filename = str_replace("_"," ",$file);
$fileloca = str_replace(" ","%20",$file);
$fileloca = str_replace("&","&", $fileloca);
$type = substr($file, -4);
if ($type == ".JPG" || $type == ".jpg"){
$size = getimagesize("$dir/$file");
$width = "$size[0]";
$height = "$size[1]";
if ( $height > $width ){
$widthheight = "width=\"75\" height=\"100\"";
$divid = "photo2";
}else{
$widthheight = "width=\"100\" height=\"75\"";
$divid = "photo1";
}
echo "<div id=\"$divid\"><a href=\"index.php?dir=$fileloca&prevdir=$dir&fileloca=$fileloca&view=1\"><img alt=\"$file\" src=\"$dir/$fileloca\" border=\"0\" $widthheight /></a></div>";
}else{
echo "<span class=\"albumname\"><a href=\"index.php?dir=$fileloca&prevdir=$dir\"><div id=\"album\">$filename</span></a></div>";
//<img alt=\"album\" src=\"images/album.gif\" border=\"0\" width=\"100\" height=\"100\" />
}
}
closedir($handle);
The spacing is probably off, as I didn't have time to mess with it. Also, the above code does NOT include links, as I didn't know where/how you wanted to link, but this would be how you do it:
$page_list = '';
for($i = 0; $i <= $num_pages; $i++) if($page == $i) $page_list .= "Page $i | "; else $page_list .= "<a href=\"myscript.php?page=$i\">Page $i</a> | ";
echo rtrim($page_list, '| ');
This code is completely untested, but give it a shot.
EDIT: $limit in the code is the max # of pics per page, btw. Forgot to mention that :p