Jump to content

Photo Gallery Next Links


Way Out West

Recommended Posts

Hi all,

Got a simple photo gallery script running which I have written and now want to extend. What I have is my selection from the MySQL database which provides a list of filenames based on the users search or gallery they choose to look at.

Obviously this selection it brings back can be any file and not consecutive. Is there any way to write in a next link which instead of saying this file is 1.jpg the next is 2.jpg would look at the selection and say this file is 1.jpg the next one in the selection is 104.jpg and link to it?

Thanks guys.
Link to comment
https://forums.phpfreaks.com/topic/34581-photo-gallery-next-links/
Share on other sites

The easiest way to do what you're after is to set up criteria for pulling associated files. So, if I view a gallery that has 1.jpg and then 104.jpg, I can have those image names stored next to each other in an array. If you set it up this way and depend on the array to pull the proper image, you don't have to link to a specific image, but rather you link to a position in the array. When your page reloads, if the criteria is the same, you know that your array contains the proper images, and you simply link to the next array position.

Hope this helps.
[quote author=obsidian link=topic=122819.msg506979#msg506979 date=1169052776]
The easiest way to do what you're after is to set up criteria for pulling associated files. So, if I view a gallery that has 1.jpg and then 104.jpg, I can have those image names stored next to each other in an array. If you set it up this way and depend on the array to pull the proper image, you don't have to link to a specific image, but rather you link to a position in the array. When your page reloads, if the criteria is the same, you know that your array contains the proper images, and you simply link to the next array position.

Hope this helps.
[/quote]

Yes, listen to OBSIDIAN! lol the only thing I can add is using "array_push" , and "array_pop" are usefull here.  Basically you want to treat the gallery in two stacks, a before and after.  So if you have 1.jpg in the before array with 104.jpg beneath it when you click next it will "pop" 1.jpg into the after array and move 104.jpg to the top of before.  Then just push 1.jpg by clicking back to add it back to the before array.  This may be more useful with VB but should work with php as well.

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.