tjhilder Posted December 28, 2006 Share Posted December 28, 2006 I'm trying to create an addon for my gallery that basicly says "Viewing XX of XX in xxcategoryxx" but I'm running into some problems.first I thought i'd try just using the $_GET['id'] in connection with the id in the mysql table to get the the Viewing [b]XX[/b] of XX which works fine so long as you don't delete any rows from the mysql database, so I need something that shows what mysql row i'm onI thought maybe $counting = current($row); would work but it's doing the same thing as if it was counting the id from the databasesay if theres' 5 pics but you deleted one like this..id | pic1 12 24 45 5i want it to show up like thisid 1 gets you 1 of Xid 2 gets you 2 of xid 4 gets you 3 of xid 5 gets you 4 of xand so on, but I can't seem to find anything that works atm.my query:[code]SELECT photo_url, photos.album_name, photos.album_id, photo_views FROM photos LEFT JOIN albums ON photos.album_id=albums.album_id WHERE (photos.album_name='{$category'ANDphoto_url='{$photoid}')[/code] Quote Link to comment https://forums.phpfreaks.com/topic/32026-showing-x-of-x-photos-problem/ Share on other sites More sharing options...
fenway Posted December 30, 2006 Share Posted December 30, 2006 Well, you could use a mysql counter, but why not number these in the output ? Quote Link to comment https://forums.phpfreaks.com/topic/32026-showing-x-of-x-photos-problem/#findComment-149968 Share on other sites More sharing options...
tjhilder Posted December 31, 2006 Author Share Posted December 31, 2006 I managed to figure it out, here's my query.[code]SELECT COUNT(photo_url) FROM photos WHERE (album_name='{$category}') AND (photo_url BETWEEN 1 AND {$photo_id})) AS current_count[/code]I used a subquery so that I could give it it's own WHERE clause which I used to count the number of rows between 1 and the photo_id of the album_id which you would have been viewing, to count how what the [b]XX[/b] of XX would be regardless of what the the $_GET id would be. Quote Link to comment https://forums.phpfreaks.com/topic/32026-showing-x-of-x-photos-problem/#findComment-150545 Share on other sites More sharing options...
fenway Posted January 3, 2007 Share Posted January 3, 2007 You still shouldn't be using the ID as the counter... Quote Link to comment https://forums.phpfreaks.com/topic/32026-showing-x-of-x-photos-problem/#findComment-151873 Share on other sites More sharing options...
tjhilder Posted January 3, 2007 Author Share Posted January 3, 2007 are you refering to a COUNT() ? or something else because I don't know.and what do you mean by not using the ID as a counter? do you mean the photo_id on my table? or something else? Quote Link to comment https://forums.phpfreaks.com/topic/32026-showing-x-of-x-photos-problem/#findComment-152046 Share on other sites More sharing options...
fenway Posted January 3, 2007 Share Posted January 3, 2007 When you delete photo_id 3, your counter will be off. Quote Link to comment https://forums.phpfreaks.com/topic/32026-showing-x-of-x-photos-problem/#findComment-152520 Share on other sites More sharing options...
tjhilder Posted January 4, 2007 Author Share Posted January 4, 2007 Ok so what would you suggest? any links to relative information would be helpful if you can provide some?TJ Quote Link to comment https://forums.phpfreaks.com/topic/32026-showing-x-of-x-photos-problem/#findComment-152801 Share on other sites More sharing options...
fenway Posted January 5, 2007 Share Posted January 5, 2007 Like I said, when you output your photos in PHP, keep a counter, and output it then. Quote Link to comment https://forums.phpfreaks.com/topic/32026-showing-x-of-x-photos-problem/#findComment-153274 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.