Page 1 of 1

Click image, go to next database item

Posted: Thu Sep 28, 2006 9:49 am
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

Posted: Fri Sep 29, 2006 10:26 am
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!!!!!

Posted: Fri Sep 29, 2006 4:47 pm
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.

Posted: Sat Sep 30, 2006 8:41 am
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.