Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Building an index for next/last in a photo album.

by waswas-fng (Curate)
on Jul 26, 2004 at 20:15 UTC ( [id://377558]=note: print w/replies, xml ) Need Help??


in reply to Building an index for next/last in a photo album.

If the next and previous are just -- and ++ the id on the current image, you can do (in psudo sql) select images from the database where the image ID is greater than or equal to ($id - 1) and image ID is less than or equal to ($id +1) ordered by id . then you just need to special case the times where the database returns < 3 results (top and bottom of the stack).


-Waswas
  • Comment on Re: Building an index for next/last in a photo album.

Replies are listed 'Best First'.
Re^2: Building an index for next/last in a photo album.
by Seumas (Curate) on Jul 26, 2004 at 20:32 UTC
    I had considered that, but the problem is that the img_id's are sequential in the database -- not the album. In other words, if I wanted img_id #43, I could not just say "give me img_id #42, #43 and #44" - because #42 and #44 could possibly belong to another album_id for the same user - or another album_id for a completely different user.

    Here is an example of the table:

    img_id | album_id | uid | name | ext -------+----------+-----+--------------+------ 38 | 14 | 89 | mypetrat | jpg 39 | 14 | 89 | mypetlemur | jpg 40 | 2 | 12 | vacation_01 | jpg 41 | 14 | 89 | mypetvulture | jpg 42 | 2 | 12 | vacation_02 | jpg 43 | 2 | 12 | vacation_03 | jpg 44 | 14 | 89 | mypetcow | jpg
      What database? if Mysql you should be able to use a more generic query that limits to the user and album and then use it's INDEX statement to say only the Item N -> N+2.


      -Waswas

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://377558]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-19 16:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found