Hi Vern,

Vern wrote:
The first recordset of thumbnails is retrieved by a URL link
($HTTP_GET_VARS['id']) which is the user's ID number.
Click on one of the thumbnails a new page is open that display the larger
photo, but only that photo. I can of course pass along the user's ID as well


which of course will allow me to create a new recordset based on the user's

FROM penpals_photos
WHERE penpals_photos.filename = $photoID

but how do I point the database first record at the photoID so that I can
use the next and previous options to see the next/previous picture?

What you are doing makes sense, but there are some other questions that must be answer.

1) How are photos and users related? i.e. what type of relationship (1-n, n:m, etc.), what tables / columns ... ?

2) What makes a thumbnail "previous" or "next"? i.e. are they sequenced by dates or some arbitrary sequence field, or ... ?

If the photos and users are related by some intermediary table, you could probably do a query like this to get all of the photos for a user:

SELECT photos.*
FROM penpals_photos photos,
     penpals_photos_x_users photos_users
WHERE photos.photoID = photos_users.photoID AND
      photos_users.userID = $userID

Just add the "ORDER BY" to order them correctly.

To get the actual "prev" or "next" given a particular photo id, you can just use > and < and the sequence column DESC/ASC order by and LIMIT 1 .... I'll leave that to you to figure out; it's not too tricky once you've got your queries to fetch all of the photos for a user in the correct order.


PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to