Jump to content

[SOLVED] pagination but not


Distant_storm

Recommended Posts

I am trying to make an image gallery type thing this is how it works

 

Large image here

 

< thumbnails here >

 

i want it to retrieve 4 thumbnails and have links to the next 4 and previous 4

 

although i dnt want to use some mucky sql statment that i don't understand.

 

unless someone can explani it.

ive read the tutorial on it but its abit vague

 

I have attempted but come to an end when i can't work out some logic to stop it retreivin photos when they don't exist.

Link to comment
https://forums.phpfreaks.com/topic/83047-solved-pagination-but-not/
Share on other sites

I would probably do most of the client side stuff in javascript unless there's a lot of images (like.... over 50).

 

Basicallly, I would make the script do this:

 

<script language="javascript">
var images = new array();
images[0] = ['thumbs/thumb1.jpg', 'images/image1.jpg'];
images[2] = ['thumbs/thumb2.jpg', 'images/image1.jpg'];
</script>

 

Then for the displaying, I would have a next link that would just replace the 4 display ones (after checking of course that there are four more).

 

 

If you wanted to avoid all of the images being in the page, you could use ajax and base it on the last image id and category to get the next 4....

 

Anyway, I doubt this helped much, but it might help with some logic.

The easiest way I know how is to alter the URL with page numbers. Then on the query, use LIMIT. That's how I made my pagination system at least. Works perfectly.

 

<?php

$query = "SELECT table_column FROM table_name LIMIT limit_per_page, number_of_pages";

?>

 

You have to calculate before hand what the variables are. Simple division should work since you know how many pics you want on 1 page and you can get the total number of pics via the database.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.