Click image, go to next database item

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
User avatar
waradmin
Forum Contributor
Posts: 240
Joined: Fri Nov 04, 2005 2:57 pm

Click image, go to next database item

Post by waradmin »

So I have a table called photos, with rows:

id : int : auto_inc : primary key
global_id : int <------- this is value $_GET['id'] in the address
album : int <--------- this is value $_GET['album'] in the address
photo_name : text
photo_desc : text
photo_url : text

Now, I have it setup so when the user is at photos.php?album=NO&id=8511657 it display's all images that user has (all photo_url associated to that global_id ($_GET['id']). Then when the user clicks on a thumbnail, it goes to something like viewphoto.php?album=2&photo=11&id=8511657. Now, that says album_id = 2, id=11 and global_id=8511657, where it will display the image with id 11 in a full-sized mode, without the other thumbnails.

How would I make it so when the user clicks on the image, it goes to the NEXT picture that matches that user ID.

For example, say the user has one album with album_id 1, and there are 5 pictures in it, with id's of 2, 9, 11, 53, 92. The user clicks on thumbnail 11, which takes them to viewphoto.php?album=1&photo=11&id=8511657, how would I make it so when the user clicks on that full size image displayed in viewphoto.php it will take them to viewphoto.php?album=1&photo=53&id=8511657, the next picture that is theirs in the photos table. Then if they click that full size image, it will take them to viewphoto.php?album=1&photo=92&id=8511657, and so on.

Ive tried some stuff, but come up with it not working every time.

Thank you very much in advance.

-Steve
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Post by andym01480 »

I would do the query the first time round and store the id's in a session variable array?

Then have two variables that are passed in the url - where you are in the array and how big the array is

Check for those two variable sto be set with integers. If not then do the query to find that user's ids.

Hope that makes sense and that session variables can be an array!!!!!
User avatar
waradmin
Forum Contributor
Posts: 240
Joined: Fri Nov 04, 2005 2:57 pm

Post by waradmin »

Would it be a problem if I am already using sessions to store the users Uname to associate their accout to their login? Right now I am always using $_SESSION['Uname'] to fetch the uname from their session and cant lose that informaton.
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

$_SESSION is array and you can assign unlimited elements to it, until you dont overwrite the $_SESSION['Uname'] it will be kept during the session lifetime.
Post Reply