Populating page using mysql db, and next and previous button

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
mattyboi
Forum Commoner
Posts: 34
Joined: Mon Feb 06, 2006 9:42 pm

Populating page using mysql db, and next and previous button

Post by mattyboi »

Hey guys,

This is a little hard to explain so bare with me. If you go to http://www.phoenixmason.com/newsite/gal.php you can get a better idea of what I am trying to do.

First off my db table is orginized in this way:
ImgKey (auto increments)
ImgType (pertaining to the buttons in the gallery)
ImgName (name of image)

When you click a button from the initial gallery page, my plan is to pass a query string to the next page with the appropriate ImgType. On the next page I need to grab all the records in the table with that ImgType. (you can see the next page by clicking the first button)

Thats the easy part. I am a little stuck on what to do about displaying the images with the "next" and "previous" buttons while only using one page.

On the initial load of the second page I want to display the first Image of that ImgType and check to see if there is another record in the table with the same ImgType. If there is I then want to show the "next" button and once you click it display the next image. And so on and so forth.

I would like not to have to reload the buttons everytime you hit the "next" and "previous" buttons, so I'm thinking I will have to use either javascript or frames.

Any suggestions on how I can go about doing this efficiently would be very helpful. Also if you could tell me the sql function on how to check to see if there is a next and previous record in a table, that would be helpful too.

Thanks a million

Matt
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Smells like pagination. We've had so many topics on this that I'll just direct you to the name.
Post Reply