If you have for example 6 images per page and click on 'next' link, you will get the next 6 images but the old one remains on the page so there are 12 images.
I'm not quite sure how to go about this when i'm using arrays, do I need to use array_chunks? I've tried but can't figure out how to get it work so any help would be good.
Thanks
--lunartek
Code: Select all
if (file_exists($_SERVER['DOCUMENT_ROOT']."$dirname")){
$dir = opendir($_SERVER['DOCUMENT_ROOT']."$dirname");
$i=1;
$count=0;
$increment = $rows*$cols-1;
$begin = (!empty($_GET['show']) && is_numeric($_GET['show']) && $_GET['show'] > 0) ? $_GET['show'] : 1;
$end = $begin + $increment;
$filearr = array();
while ($filename = readdir($dir)) {
if (ereg ("(.*)\.gif", $filename)) {
$filearr[] = $filename;
}
}
closedir($dir);
sort($filearr);
reset($filearr);
if (count($filearr) > 0){
echo "<table border=0 cellspacing=0 cellpadding=2>";
for ($i>=$begin; $i<=$end; $i++){
$imagesize = getimagesize($_SERVER['DOCUMENT_ROOT']."$dirname"."$filearr[$count]");
if ($imagesize[0]=="$width" && $imagesize[1]=="$height"){
echo "<td><img src="http://".$_SERVER['SERVER_NAME']."$dirname"."$filearr[$count]"."" width=$width height=$height></td>";
$count++;
if ($i%3==0){ echo "<tr></tr>"; }
}
}
echo "</table>";
}
echo "<BR><a href="".$_SERVER['PHP_SELF']."?"."&show=".($i)."">next</a>";