Jump to content

Showing x of x photos problem


tjhilder

Recommended Posts


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 on

I thought maybe $counting = current($row); would work but it's doing the same thing as if it was counting the id from the database

say if theres' 5 pics but you deleted one like this..

id  |  pic
1      1
2      2
4      4
5      5

i want it to show up like this

id 1 gets you 1 of X
id 2 gets you 2 of x
id 4 gets you 3 of x
id 5 gets you 4 of x

and 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'
AND
photo_url='{$photoid}')[/code]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.