简体   繁体   中英

How do I set up pagination for an image gallery with image thumbnails?

I have two tables here:

Gallery
ID | Name | Description

Image
ID | Title | Caption | GalleryID

I got the code all set to make a simple image gallery by listing all the thumbnails or paging through the thumbnails. However what I need to do is accomplish something like the gallery here only without the javascript and ajax:

http://gulfnews.com/pictures/news/abandoned-cars-around-uae-1.655965

I want a select number fo thumbnails to show beneath the main image and as and as teh user clicks on teh thumbnails it opens the page with the newly selected image as highlighted and the series of thumbnails on the botto moves ahead by one. if its not the last image that is.

How do I do this? I'd like a quick and dirty way to do this? I'm using php and mysql here for the database - just need the code to show the 'paginated'images below the main image. i know how to set up everything else ie thumbnails resizing etc...

I don't know if MySQL has a ROWNUMBER() function like T-SQL for numbering your rows, but the smart way to do it is to have a sequential numbering of your images in the database. From there, you query your database by saying something like:

SELECT TOP [images_per_page] WHERE Row_Number > [images_per_page] * [page_number - 1].

That way you only pull back the data you need. You keep track of the page number, most likely in your query string.

That's pretty simplistic, but hopefully it gives you an idea of how to start.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM