image gallery

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sh33p1985
Forum Commoner
Posts: 78
Joined: Thu Mar 11, 2004 9:22 am

image gallery

Post by sh33p1985 »

looking at making a basic image gallery, getting the images from a directory and storing them for use is simple enough. though i want to have 4 actions "first", "next", "prev" "last" that the user can click and a new image is displayed. again the code for these actions are simple enough; but how do you actually call these functions from say a <a href="">Next</a>

i thought you might be able to direct to user to image_gallery.php?action=next and catch that and perform the correct action before displaying the correct image.

am i along the right lines?
User avatar
jayshields
DevNet Resident
Posts: 1912
Joined: Mon Aug 22, 2005 12:11 pm
Location: Leeds/Manchester, England

Post by jayshields »

Search: pagination
sh33p1985
Forum Commoner
Posts: 78
Joined: Thu Mar 11, 2004 9:22 am

Post by sh33p1985 »

pagination wouldnt quite suit what im after imo. i literally would like to display 1 image (first image in directory) with navigation options to allow the user to go to the first image, the previous image, the next image, the last image (in the directory). none of this information will involve a database it will take the directory and put it into an array and these functions will manipulate the pointer within the array.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

It's still pagination, just with 1 item per page instead of 10, 20, 100, or whatever items. The principle is identical.
sh33p1985
Forum Commoner
Posts: 78
Joined: Thu Mar 11, 2004 9:22 am

Post by sh33p1985 »

ok ill agree with you there, but doesnt pagination primarily work for data stored in a database?
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

sh33p1985 wrote:ok ill agree with you there, but doesnt pagination primarily work for data stored in a database?
Pagination is simply the act of paging through a list of things. It doesn't matter if they're database records, an array, a glob of files... the code is the same. The only thing that's different is how you make the list in the first place.
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Hi! My missis wanted a gallery recently and I wrote her a super simple one which you can look at here. It is one self contained script and there is a second script to admin it. No database! No sessions! No cookies! No Javascript! The admin script makes a thumbnail and resizes the image to a reasonable size. It will even run through a directory on the server that contains multiple images and thumbnail and load them. If you would like the code I can post it.
Post Reply