hello gurus!
i have a folder name comment in my root directory...and inside that folder are images or gif....now what i wanted, is to display those images with pagination...let say 4 images per page...
and here's what i got so far...the problem is that in my main page it display 3 images as what i declared in the $rpp variable...but when i press the link 1 (view_pix.php?page=1) it will now display 4 images instead of only 3, the same with the following pages...and i also noticed that the last image in every pages is still present on its next page...and its placed first in the row...
i really don't know how to fix this one...i really need ur help...
any help is very appreciated....tnx in advanced!
PHP Code:
<?php
$page = $_GET['page']; $rpp = 3; $c = 0; $handle = opendir('comments/'); $d = opendir("comments/"); $count = 0; while(($f = readdir($d)) !== false) if(ereg('.gif$', $f)) ++$count; closedir($d); print "$count"; $numOfPages = ceil( $count / $rpp ); if($handle) {
while(false !== ($file = readdir($handle))) {
if(preg_match("/\w+(.gif)/",$file)) {
$c++; if ($c > (($page * $rpp) + $rpp)) break; if ($c >= ($page * $rpp)) { echo "<div class='update_pics_frame'>"; echo "<div class='update_pics'>"; echo "<a href='comments/$file'><img src='comments/$file' width='200'border='0'></a>"; echo "</div>"; echo "</div>"; } } } closedir($handle); }
for ($i = 1; $i <= $numOfPages; $i++) { echo "<a href='view_pix.php?page=$i'>"; echo " ".$i." "; echo "</a>"; }
?>
Last edited by paparanch; 03-01-2009 at 09:53 PM..
Reason: wrong spelling
|