jimmyoneshot Posted September 19, 2011 Share Posted September 19, 2011 I am creating a php image gallery and currently have a query in place which gets all of the details on the current photo being viewed on a user's:- SELECT DISTINCT (SELECT count(photos.id) FROM photos WHERE photos.author_id = $authorid) AS photo_count, photos.id, photos.name, photoAlbums.id AS album_id, photoAlbums.name AS album_name FROM z_photos LEFT JOIN photoAlbums ON (photos.album_id = photoAlbums.id) WHERE photos.id = $photoid AND photos.author_id = $authorid I now need a subquery in the above which somehow gets the position of the photo within the current selection. For example the code posted above is used to show all of the details on a photo posted by the user currently being viewed as well as the count of how many photos the user has posted but above each currently selected photo I want to show a message saying photo ??? of ???. So basically I have the total number of photos from the subquery in the above query but I now need a subquery to get the photos position in the selection. For example if the 'photo_count' produced by the above query was 17 and the user was viewing the second photo it would show photo 2 of 17. How can I do this in one query or via php? Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted September 20, 2011 Share Posted September 20, 2011 how do you actualy KNOW what photo number any given image is with respect to an album? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.