Results 1 to 7 of 7

Thread: Adding Pagination to Gallery Script

  1. #1
    Join Date
    Mar 2006
    out in the boondocks of London, Ohio

    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 =]
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2006
    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()

  3. #3
    Join Date
    Mar 2006
    out in the boondocks of London, Ohio
    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..

  4. #4
    Join Date
    Jun 2006
    Down at the bottom of the garden
    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.
    Quote Originally Posted by temp.user123
    You know... You're not so smart. Do you need me to educate you?
    If you say, "please," (and do so, nicely) then I will show you where you're dead wrong.

  5. #5
    Join Date
    Feb 2006
    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";

  6. #6
    Join Date
    Dec 2007
    any link(s) to see a working sample?

  7. #7
    Join Date
    Mar 2008
    Hey I have an idea for you.. you could encapsulate each set of images in divs with a class. And control them with javascript:

    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>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center