I have read alot of messages about basic pagination. However none appear to deal with the issue where the number of items to be displayed on each page varies. In my case, I am creating a thumbnail gallery of product images. The images are either landscape or portrait, and the page may conntain a mixture of the two. Therefore depending on the orientation of the images, the total amount of images that can be displayed on the page will vary. I would appreciate advice on how best to implement pagination for this scenario. Here is the page that currently does not have any pagination http://www.trullcornershop.co.uk/inside2.php Many thanks Paul
Hi there The details of all the images are stored in a database. I don't actually store the image itself in the database - just the path. Thanks Paul
OK, when you store the image path in the database you could also store the image dimensions as well. Using the image width info (i noticed your images are all the same height) you can work out if 'x' amount of images will fit on the row, if not start the next row. Call enough of the images to fit the page, which will probably be either 9 or 12, then loop through them working out if they fit on the row, when you have filled three rows you may have some images not shown from the result set. In that case count how many were not shown and adjust your next database call to start that number of lines back. If you can't store the image dimensions in the database you can always get them using getimagesize(); Hope this helps - and you understand my ramblings!
Thanks gawk - I really appreciate the help! What you suggests sounds like a great solution - there should be no problem storing the images in the database as I resize all the uploaded images anyway. I will give your solution a try! Many thanks Paul