in reply to next prev record mysql table

Despite what has been said in another reply - NEVER RELY ON THE ORDER IN WHICH DATA IS RETURNED. In MySQL it is possible that ANY change of the data in a table will change the order of items being returned

I would have an indentity field in each record which could be an auto-incremented value (one counter for all users) then when you select the records for a single user you can retrieve them ordered by ID. Then do one of two things, either embed the ID for the next and previous. Or you can do a query which asks for ID > lastID for the next record or ID < lastID for the previous.

This way, the user could add a new image while somebody is scanning through them and the new one would be found at the end.

Their are a number of more sophisticated ways to handle this. I wrote a gallery for internal use here a couple of years ago. The user uploads the images in any order they like, then Using a simple interface they can create the sequence they wish the images to appear in. This creates a hash which is stored in their user record which maps sequence number to ID. They can edit the list to insert a new image into the sequence or remove one.

Good luck! jdtoronto