PDA

View Full Version : Pagination in Gallery


sajjad
01-28-2006, 07:40 PM
After many hours i finally got a code to display images with thumbnails, but the problem is that i want 2 images per page. How can i do this with pagination like
Prev 1 2 3 Next

This is the code I used to get images:

$handle_dir = opendir($p);
$x = 0;

while($file = readdir($handle_dir))


{
if($file!="." && $file!=".." && $file!="thumbs")
{
echo "<a target='_blank' href='". $p."/".$file."' ><img style='margin:3px;' src='".$p."/thumbs/"."$file'></a>";
$x++;
}
}


how can i make pages for them

Velox Letum
01-28-2006, 07:45 PM
What I do is load all of the elements into an array, then use simple math to display them (offset + 1, offset + 2) for the array elements, then ceil() the total elements divided by two and that gives you the pages. Sorry I can't give more of an example, but I have to run.