Adding Pagination to Gallery Script
I have a php gallery that automatically creates thumbnails via GD. I have attached the php file within a zip file.
What I would like to have help with is I'm not sure how to add pagination to it. I'd like only 6 thumbnails to show up per page and have a type of navigation to go through the pages for a particular album.
Any help would be greatly appreciated! Thanks =]
you have to select the appropriate images from db of elsewhere
for db you use - LIMIT from,to (WHERE 1 LIMIT 150,156)
will show you 6 images on page 26 (156/6)
for while use for()
The thing is -- this script doesn't use a database -- I know how to do it if there was, but I'm building a website for a friend and their host allows php code but no database..
Get the total amount of images divided by amount per page, in your case 6 this gives us the total number of "pages". (Use ceil())
Use a $_GET variable to store the current page number, we will call this $_GET["page"], default is 0.
Then simple build a sorted array of all the images in a folder and array_shift() 6 * $_GET["page"] images before displaying the final 6 images you want to display.
Originally Posted by temp.user123
I bet if she knows how to use limit she would deal with GET parameters.
Where do you store your images ?
In a folder getting them into array by readdir ?
You should sort you array by file's creation time back to front to ensure you have the latest newest images on the first page. use multisort and filectime
Then you just output them even not in cycle
< img src='createthubnail.php?img=".( intval($_GET['s']) + 1) ."'>
< img src='createthubnail.php?img=".( intval($_GET['s']) + 6) ."'>
echo "<a href='?".($s+7)."'>nextpage";
any link(s) to see a working sample?
link 1: onclick hide all except firstSet
link 2: onclick hide all except secSet
<div class="firstSet">lalalal 5 thumbs here alal</div>
<div class="secSet">lalalal alal</div>
<div class=thirdSet">lalalal alal</div>
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)