image - PHP/MYSQL - User Photos Prev/Next link -


My project has a user account, which has photos of each user that they have uploaded

Like to show a next and previous picture for each user, so when I go to the Friends list of pictures, I can navigate to the next uploaded users (obviously). I will be fine with these pictures next with the next / previous picture.

How would you write that kind of query for one / next photo?

My table structure is similar, it is not so.

  If user does not have it then 'userphotos' (`photo_id` int (11) does not auto_interpret,` photo_ownerid` int (11) no, zero, `photo_right` integer (11 ) No tap, `photo_name` (100) no tap,` photo_ caption '(100) tap, `photo_imagegeta` is not long tap, album_id_t (11) faucet, primary (` photo_id`)) Engine = mysome default charset = latin1 AUTO_INCREMENT = 89;   

Will I use something like this to choose from the

pre image

  SELECT field1, from where Tablename WHERE id & lt; $ Currentid ORDER ID DESC limit 1   

Next image

  SELECT field1 to tablename ID; $ Currentid ORDER ID ASC limit1    

What those questions should do for you . Although you should include the owner ID to limit the photos that will be browsed by the user's ownership.

Previous image

  SELECT field1WERE id from Tablename   

Next image

  SELECT field1 to Tablename WHERE ID & Gt; $ CurrentId and photo_ownerid = $ ownerId ORDER ID ASC limit1   

However, as the question has been indicated in the comment, every time you want to see the database, the next / previous picture example For, you can ask all photos at once, for example, use the Javascript library so that the photos can organize and navigate systematically.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -