cloevvold Posted October 27, 2007 Share Posted October 27, 2007 I have been trying to ask this question i several forums in my country "Norway", and it seems like nobody can help me, so i really hope someone can do it here. I have a script, that i really like a lot, and that I want to use, but pagination is missing This is a image gallery script, and the way it works is that it pics up the images that is in the folder that the php file is stored in. It create thumbnails for me automaticly, and crop them to perfect squares, whitout ditorting the image (something that i really like) It sorts the images, so the latest image uploaded to the folder comes first, no matter what the name of the image is. I can conrol collums... Basicly i like the script the way it is, and dont want any of the functions it haves to ba taken away. This is how it looks like now: http://www.cloevvold-photo.com/TEST_SCRIPTS/test/landskap/ But I cant controll rows.. witch is bad.. I would like to be able to control how many rows i want to use, and when the collums and rows are filled in, i would like the pagination to appear below the thumbnails.. I have seen a video about pagination.. and i really like the way that the pagination is there.. but its require a database.. The file I have now, is only 1 file, and requiers no database, and I would really like it to stay that way. Is it possible to get the same kind og Pagination that you see in this video: http://www.sampsonvideos.com/videos/PHP/PHP_Pagination/ whitout the use of a database, and that it still is the 1 file I have?? I really hope that someone here cab help me..??? This is the script I have: <?php $thumb_size = 100; $columns = 5; $rows = 1; function resizeImage($source) { global $thumb_size; $size = getimagesize($source); $width = $size[0]; $height = $size[1]; if($width > $height) { $x = ceil(($width - $height) / 2 ); $width = $height; } elseif($height > $width) { $y = ceil(($height - $width) / 2); $height = $width; } $new_im = imagecreatetruecolor($thumb_size,$thumb_size); $im = imagecreatefromjpeg($source); imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height); return $new_im; } function generateThumbnails(){ // Open the actual directory if ($handle = opendir(".")) { // Read all file from the actual directory while ($file = readdir($handle)) { // Check whether tha actual item is a valid file if (is_file($file)){ // Check whether the actual image is a thumbnail if (strpos($file,'_th.jpg')){ $isThumb = true; } else { $isThumb = false; } if (!$isThumb) { // Process the file string $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,'.')); // Check if the actual file is a jpeg image if (($extName == '.jpg') || ($extName == '.jpeg')){ $thmbFile = $dirName.'/'.$fileMain.'_th.jpg'; // If a thumbnail dosn't exists tahn create a new one if (!file_exists($thmbFile)){ imagejpeg(resizeImage($file),$thmbFile,80); } } } } } } } function getNormalImage($file){ $base = substr($file,0,strrpos($file,'_th.jpg')); if (file_exists($base.'.jpg')) return $base.'.jpg'; elseif (file_exists($base.'.jpeg')) return $base.'.jpeg'; else return ""; } function displayPhotos(){ global $columns; generateThumbnails(); // Open the actual directory if ($handle = opendir(".")) { // Read all file from the actual directory while ($file = readdir($handle)) { // Check whether tha actual item is a valid file if (is_file($file)){ // Check whether the actual image is a thumbnail if (strpos($file,'_th.jpg')){ $fil = ereg_replace("_th.jpg",".jpg",$file); $time = filemtime($fil); $normal = getNormalImage($file); $bilde[$time] = $file; } } } if (isset($bilde)) { $count = count($bilde,1); display($bilde,$count); } else { echo "Det er desverre ikke noen bilder her!"; } } } function display($file,$count) { global $columns,$rows; $max_site = ceil(($columns * $rows) / $count); krsort($file); $act = 0; foreach ($file as $time => $fil) { $i++; ++$act; if ($act > $columns) { echo '</tr><tr><td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; $act = 1; } else { echo '<td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; } } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <title>Cecilie Løvvold Photography</title> <link href="../style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div class="caption">Landskap</div> <table align="center"><tr> <?php displayPhotos(); ?> </table> </div> </body> Quote Link to comment Share on other sites More sharing options...
cloevvold Posted October 27, 2007 Author Share Posted October 27, 2007 Oki.. I see that it can be wer dificould to make this whitout a database.. But If I do use a database.. can someone halp me here than? I have a code to a Pagination script.. can someone help me make that code work with my gallery code? This is the code to Pagination: <?php // User-credentials $host = "localhost"; $user = "root"; $pass = "my secret password"; £data = "photo_gallery"; // Establish connection, and select db $conn = mysql_connect($host, $user, $pass) or die(mysql_error()); mysql_select_db(data, $conn) or die(mysql_error()); // Create some varibles $pageNumber = (isset($_GET["page"]) && is_numeric($_GET["page"])) ? $_GET["page"] : 1; // Establish number of results per page $perPage = 10; // Establish a padding value $padding = 5; // Get Start index of results $startIndex = (pageNumber * $perPage) - $perPage; // Get total number of database entries $totalCount = "SELECT COUNT (*) as 'Total' FROM mysql.page_number"; $rsCount = mysql_query(totalCount, $conn) or die(mysql_error()); $rowCount = mysql_fetch_object($rsCount); // Show Page Listings print "<div align=\"center\">"; // Get our total number of pages $numOfPages = ceil($rowCount->Total / $perPage); // Print link to first page print "<a href=\"index.php?page=1\">FIRST</a> "; // If our current page, minus our padding, is greater than 1 if(($pageNumber - $padding) > 1) { print "... "; // Set our lower limit $lowerLimit = £pageNumber - $padding; // Print all padded numbers between loverLimit and curretn page for($i = $lowerLimit; $i < $pageNumber; $i++) { print "<a href=\"index.php?page=".$i."\">".$i."</a> "; } } else { // Print all numbers between current page, and first page for($i = 2; $i < $pageNumber; $i++) { print "<a href=\"index.php?page=".$i."\">".$i."</a> "; } } // If we're not on the first page, or the last page, print current page if(($pageNumber != 0) && ($pageNumber != 1) && ($pageNumber != $numOfPages)) { print "<b> - " . $pageNumber . " - </b>"; } // If our current page, plus our padding, is less than the total number of pages if(($pageNumber + $padding) < $numOfPages) { // Set upper limit $upperLimit = $pageNumber + $padding; // Print all numbers from padded page above current page for($i = (pageNumber + 1); $i <= $upperLimit; $i++) { print "<a href=\"index.php?page=".$i."\">".$i."</a> "; } print "... "; } else { // Print all page numbers between number of pages and current pages for($i = ($pageNumber + 1); $i < $numOfPages; $i++) { print "<a href=\"index.php?page=".$i."\">".$i."</a> "; } } // Print link to last page print "<a href=\"index.php?page=".$numOfPages."\">LAST</a>"; print "</div>"; // Get page results $sql = "SELECT page_number_id, name FROM page_number ORDER BY page_number_id LIMIT $startIndex, $perPage"; // Get result set $rs = mysql_query($sql, $conn) or die(mysql_error()); // Do we have results? if(mysql_num_rows($rs) > 0) { //Show the results while($row = mysql_fetch_object($rs)) { print "<div>"; print $row->page_number_id; print ": "; print $row->name; print "</div>"; } else { print "Sorry, no results found."; } // Close our database conection mysql_close($conn); ?> And if someone can help me.. Please write down how the table should look like in PhpMyadmin.. Im really new at this Quote Link to comment Share on other sites More sharing options...
sasa Posted October 28, 2007 Share Posted October 28, 2007 try <?php $thumb_size = 100; $columns = 5; $rows = 2; $dir = '.'; function resizeImage($source) { global $thumb_size; $size = getimagesize($source); $width = $size[0]; $height = $size[1]; if($width > $height) { $x = ceil(($width - $height) / 2 ); $width = $height; } elseif($height > $width) { $y = ceil(($height - $width) / 2); $height = $width; } $new_im = imagecreatetruecolor($thumb_size,$thumb_size); $im = imagecreatefromjpeg($source); imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height); return $new_im; } function generateThumbnails($dir='.'){ // Open the actual directory if ($handle = opendir($dir)) { // Read all file from the actual directory while ($file = readdir($handle)) { // Check whether tha actual item is a valid file if (is_file($file)){ // Check whether the actual image is a thumbnail if (strpos($file,'_th.jpg')){ $isThumb = true; } else { $isThumb = false; } if (!$isThumb) { // Process the file string $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,'.')); // Check if the actual file is a jpeg image if (($extName == '.jpg') || ($extName == '.jpeg')){ $thmbFile = $dirName.'/'.$fileMain.'_th.jpg'; // If a thumbnail dosn't exists tahn create a new one if (!file_exists($thmbFile)){ imagejpeg(resizeImage($file),$thmbFile,80); } } } } } } } function getNormalImage($file){ $base = substr($file,0,strrpos($file,'_th.jpg')); if (file_exists($base.'.jpg')) return $base.'.jpg'; elseif (file_exists($base.'.jpeg')) return $base.'.jpeg'; else return ""; } function displayPhotos($dir = '.'){ global $columns,$bilde; generateThumbnails($dir); // Open the actual directory if ($handle = opendir($dir)) { // Read all file from the actual directory while ($file = readdir($handle)) { // Check whether tha actual item is a valid file if (is_file($file)){ // Check whether the actual image is a thumbnail if (strpos($file,'_th.jpg')){ $fil = ereg_replace("_th.jpg",".jpg",$file); $time = filemtime($fil); $normal = getNormalImage($file); $bilde[$time] = $file; } } } if (isset($bilde)) { $count = count($bilde,1); display($bilde,$count); } else { echo "Det er desverre ikke noen bilder her!"; } } } function display($file,$count) { global $columns,$rows; $per_page = $columns * $rows; $no_of_pages = ceil($count / $per_page); if (isset($_GET['page'])) $page = (int) $_GET['page']; else $page = 1; $end = $page * $per_page; $start = $end - $per_page; $max_site = ceil(($columns * $rows) / $count); krsort($file); $act = 0; $i = 0; foreach ($file as $time => $fil) { if(++$i > $start and $i <= $end){ ++$act; if ($act > $columns) { echo '</tr><tr><td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; $act = 1; } else { echo '<td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; } } } echo '</tr></table>'; if ($page > 1) echo ' <a href="?page=',$page-1,'">prev</a> '; else echo ' prev '; for ($i = 1; $i <= $no_of_pages; $i++) if($i != $page) echo ' <a href="?page=',$i,'">',$i, '</a> '; else echo ' ',$i, ' '; if ($page < $no_of_pages) echo '<a href="?page=',$page+1,'"> next </a>'; else echo ' next '; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <title>Cecilie Løvvold Photography</title> <link href="../style/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div class="caption">Landskap</div> <table align="center"><tr> <?php displayPhotos(); ?> </div> </body> Quote Link to comment Share on other sites More sharing options...
cloevvold Posted October 28, 2007 Author Share Posted October 28, 2007 WOW sasa... Thanks a lot.. and whitout a database, just what I wanted. I just need to ask if it is possible to nudge it a little bit Is it possible to make it look like this: That only 5 pages is visible all the time.. and a link to first and last page.. and << and >> works like next and prev?? That would be just absolutely great Quote Link to comment Share on other sites More sharing options...
sasa Posted October 28, 2007 Share Posted October 28, 2007 change function display function display($file,$count) { global $columns,$rows; $per_page = $columns * $rows; $no_of_pages = ceil($count / $per_page); if (isset($_GET['page'])) $page = (int) $_GET['page']; else $page = 1; $end = $page * $per_page; $start = $end - $per_page; $max_site = ceil(($columns * $rows) / $count); krsort($file); $act = 0; $i = 0; foreach ($file as $time => $fil) { if(++$i > $start and $i <= $end){ ++$act; if ($act > $columns) { echo '</tr><tr><td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; $act = 1; } else { echo '<td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; } } } echo '</tr></table>'; if ($page > 1) echo ' <a href="?page=1">First Page</a> '; else echo ' First Page '; if ($page > 1) echo ' <a href="?page=',$page-1,'"><<</a> '; else echo ' << '; $midle_page = $page; if ($page < 3) $midle_page = 3; else if ($no_of_pages - $page < 2) $midle_page = $no_of_pages - 2; for ($i = 1; $i <= $no_of_pages; $i++) if(abs($midle_page - $i) <= 2) if($i != $page) echo ' <a href="?page=',$i,'">',$i, '</a> '; else echo ' ',$i, ' '; if ($page < $no_of_pages) echo ' <a href="?page=',$page+1,'">>></a> '; else echo ' >> '; if ($page < $no_of_pages) echo ' <a href="?page=',$no_of_pages,'">Last Page</a> '; else echo ' Last Page '; } Quote Link to comment Share on other sites More sharing options...
cloevvold Posted October 28, 2007 Author Share Posted October 28, 2007 WOW... amazing One last question, how do I get it to be in the center.. and is it possible to make a class to in the css file that is attach to it? say I want to make a class called: .page_number Quote Link to comment Share on other sites More sharing options...
sasa Posted October 28, 2007 Share Posted October 28, 2007 function display($file,$count) { global $columns,$rows; $per_page = $columns * $rows; $no_of_pages = ceil($count / $per_page); if (isset($_GET['page'])) $page = (int) $_GET['page']; else $page = 1; $end = $page * $per_page; $start = $end - $per_page; $max_site = ceil(($columns * $rows) / $count); krsort($file); $act = 0; $i = 0; foreach ($file as $time => $fil) { if(++$i > $start and $i <= $end){ ++$act; if ($act > $columns) { echo '</tr><tr><td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; $act = 1; } else { echo '<td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; } } } echo '</tr></table>'; echo '<div align="center" class="page_number">'; if ($page > 1) echo ' <a href="?page=1">First Page</a> '; else echo ' First Page '; if ($page > 1) echo ' <a href="?page=',$page-1,'"><<</a> '; else echo ' << '; $midle_page = $page; if ($page < 3) $midle_page = 3; else if ($no_of_pages - $page < 2) $midle_page = $no_of_pages - 2; for ($i = 1; $i <= $no_of_pages; $i++) if(abs($midle_page - $i) <= 2) if($i != $page) echo ' <a href="?page=',$i,'">',$i, '</a> '; else echo ' ',$i, ' '; if ($page < $no_of_pages) echo ' <a href="?page=',$page+1,'">>></a> '; else echo ' >> '; if ($page < $no_of_pages) echo ' <a href="?page=',$no_of_pages,'">Last Page</a> '; else echo ' Last Page '; echo '</div>'; } Quote Link to comment Share on other sites More sharing options...
cloevvold Posted October 28, 2007 Author Share Posted October 28, 2007 Thanks a bunch sasa... You really saved my day Quote Link to comment Share on other sites More sharing options...
cloevvold Posted October 29, 2007 Author Share Posted October 29, 2007 The pagination works perfect.. It is just one thing I would like to do.. but dont know haw to do it.. You can se an example of the script here: http://www.cloevvold-photo.com/TEST_SCRIPTS/test/galleri/landskap/ And if you go to "Last Page" you will se that the pagination jumps up with the thumbnails.. Is there a way to make the pagination stay fixed where they are, make an own table for it under the thumbnails.. that dont jumps up with it when the colums and rows are not filled in?? That would be awsome if that is possible This is the full script as it is now: <?php $thumb_size = 100; $columns = 4; $rows = 4; $dir = '.'; function resizeImage($source) { global $thumb_size; $size = getimagesize($source); $width = $size[0]; $height = $size[1]; if($width > $height) { $x = ceil(($width - $height) / 2 ); $width = $height; } elseif($height > $width) { $y = ceil(($height - $width) / 2); $height = $width; } $new_im = imagecreatetruecolor($thumb_size,$thumb_size); $im = imagecreatefromjpeg($source); imagecopyresampled($new_im,$im,0,0,$x,$y,$thumb_size,$thumb_size,$width,$height); return $new_im; } function generateThumbnails($dir='.'){ // Open the actual directory if ($handle = opendir($dir)) { // Read all file from the actual directory while ($file = readdir($handle)) { // Check whether tha actual item is a valid file if (is_file($file)){ // Check whether the actual image is a thumbnail if (strpos($file,'_th.jpg')){ $isThumb = true; } else { $isThumb = false; } if (!$isThumb) { // Process the file string $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,'.')); // Check if the actual file is a jpeg image if (($extName == '.jpg') || ($extName == '.jpeg')){ $thmbFile = $dirName.'/'.$fileMain.'_th.jpg'; // If a thumbnail dosn't exists tahn create a new one if (!file_exists($thmbFile)){ imagejpeg(resizeImage($file),$thmbFile,80); } } } } } } } function getNormalImage($file){ $base = substr($file,0,strrpos($file,'_th.jpg')); if (file_exists($base.'.jpg')) return $base.'.jpg'; elseif (file_exists($base.'.jpeg')) return $base.'.jpeg'; else return ""; } function displayPhotos($dir = '.'){ global $columns,$bilde; generateThumbnails($dir); // Open the actual directory if ($handle = opendir($dir)) { // Read all file from the actual directory while ($file = readdir($handle)) { // Check whether tha actual item is a valid file if (is_file($file)){ // Check whether the actual image is a thumbnail if (strpos($file,'_th.jpg')){ $fil = ereg_replace("_th.jpg",".jpg",$file); $time = filemtime($fil); $normal = getNormalImage($file); $bilde[$time] = $file; } } } if (isset($bilde)) { $count = count($bilde,1); display($bilde,$count); } else { echo "Det er desverre ikke noen bilder her!"; } } } function display($file,$count) { global $columns,$rows; $per_page = $columns * $rows; $no_of_pages = ceil($count / $per_page); if (isset($_GET['page'])) $page = (int) $_GET['page']; else $page = 1; $end = $page * $per_page; $start = $end - $per_page; $max_site = ceil(($columns * $rows) / $count); krsort($file); $act = 0; $i = 0; foreach ($file as $time => $fil) { if(++$i > $start and $i <= $end){ ++$act; if ($act > $columns) { echo '</tr><tr><td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; $act = 1; } else { echo '<td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; } } } echo '</tr></table>'; echo '<div align="center" class="page_number">'; if ($page > 1) echo ' <a href="?page=1">First Page</a> '; else echo ' First Page '; if ($page > 1) echo ' <a href="?page=',$page-1,'"><<</a> '; else echo ' << '; $midle_page = $page; if ($page < 3) $midle_page = 3; else if ($no_of_pages - $page < 2) $midle_page = $no_of_pages - 2; for ($i = 1; $i <= $no_of_pages; $i++) if(abs($midle_page - $i) <= 2) if($i != $page) echo ' <a href="?page=',$i,'">',$i, '</a> '; else echo ' ',$i, ' '; if ($page < $no_of_pages) echo ' <a href="?page=',$page+1,'">>></a> '; else echo ' >> '; if ($page < $no_of_pages) echo ' <a href="?page=',$no_of_pages,'">Last Page</a> '; else echo ' Last Page '; echo '</div>'; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd"> <html> <head> <title>Cecilie Løvvold Photography</title> <link href="../../css/style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="main"> <div class="caption">Landskap</div> <table align="center"><tr> <?php displayPhotos(); ?> </div> </body> And this is the css file: #main { margin: auto; border: 1px solid #cccccc; width: 800px; background: #F1F3F5; font-family: Arial, Helvetica, sans-serif; font-weight:bold; font-size : 12px; } form { margin-left: 80px; border: 1px solid #cccccc; width: 300px; background: #E9ECEF; font-family: Arial, Helvetica, sans-serif; font-weight:normal; font-size : 12px; padding:5px; margin-bottom:10px; } #result { margin-left: 80px; border: 1px solid #cccccc; width: 300px; background: #E9ECEF; font-family: Arial, Helvetica, sans-serif; font-weight:normal; font-size : 12px; padding:5px; margin-bottom:20px; } .photo { padding:10px; border: 1px solid #cccccc; background: #E9ECEF; font-family: Arial, Helvetica, sans-serif; font-weight:normal; font-size : 12px; text-align:center; } .text { border: 1px solid #cccccc; } input { border: 0px solid #cccccc; } .values{ font-family: verdana; font-weight:normal; font-size : 10px; vertical-align:top; } .key{ font-family: verdana; font-weight:bold; font-size : 12px; padding-bottom:15px; } .caption{ font-family: Arial, Helvetica, sans-serif; font-weight:bold; margin:10px; font-size : 14px; color:#C64934; } #icon{ width:80px; height:80px; float:left; background-image:url(icon.gif); background-repeat: no-repeat; background-position:center center; } #icon2{ width:80px; height:80px; float:left; background-image:url(icon2.gif); background-repeat: no-repeat; background-position:center center; } #source{ text-align:right; padding-right:10px; font-family: Arial, Helvetica, sans-serif; font-weight:normal; font-size : 10px; color:#CCCCCC; } a { text-decoration:none; border:0px; } img { border:0px; } .page_number { font-family: verdana; font-size:10px; color: #333; padding-top:10px; padding-bottom:10px; } .page_number a { text-decoration: none; padding: 3px; padding-left:5px; padding-right:5px; font-family: verdana; font-size: 10px; border: 1px solid #CCC; color: #333; background-color: #FFF; } .page_number a:hover { color: #FFF; background-color: #333; } Quote Link to comment Share on other sites More sharing options...
sasa Posted October 29, 2007 Share Posted October 29, 2007 function display($file,$count) { global $columns,$rows; $per_page = $columns * $rows; $no_of_pages = ceil($count / $per_page); if (isset($_GET['page'])) $page = (int) $_GET['page']; else $page = 1; $end = $page * $per_page; $start = $end - $per_page; $max_site = ceil(($columns * $rows) / $count); krsort($file); $act = 0; $i = 0; $xxx = 1; foreach ($file as $time => $fil) { if(++$i > $start and $i <= $end){ ++$act; if ($act > $columns) { echo '</tr><tr><td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; $act = 1; $xxx++; } else { echo '<td class="photo"><a href="'.getNormalImage($fil).'"><img src="'.$fil.'" alt="'.$fil.'"/></a></td>'; } } } echo '</tr></table>'; $margin = ($rows - $xxx) * 124; echo '<div align="center" class="page_number" style="margin-top:',$margin,'px;">'; if ($page > 1) echo ' <a href="?page=1">First Page</a> '; else echo ' First Page '; if ($page > 1) echo ' <a href="?page=',$page-1,'"><<</a> '; else echo ' << '; $midle_page = $page; if ($page < 3) $midle_page = 3; else if ($no_of_pages - $page < 2) $midle_page = $no_of_pages - 2; for ($i = 1; $i <= $no_of_pages; $i++) if(abs($midle_page - $i) <= 2) if($i != $page) echo ' <a href="?page=',$i,'">',$i, '</a> '; else echo ' ',$i, ' '; if ($page < $no_of_pages) echo ' <a href="?page=',$page+1,'">>></a> '; else echo ' >> '; if ($page < $no_of_pages) echo ' <a href="?page=',$no_of_pages,'">Last Page</a> '; else echo ' Last Page '; echo '</div>'; } Quote Link to comment Share on other sites More sharing options...
cloevvold Posted October 29, 2007 Author Share Posted October 29, 2007 Thanks a lot sasa... You are a wizzard... works perfectly Best reguards Cecilie Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.