I have a build-your-own-website website and one of the add-ons is a gallery. In my gallery table I have the following fields: id, owner, timestamp, filename, thumbname, title, description, category, ordering Currently it shows the thumbs in a list and the user clicks each thumb and it just opens the fullsize image. I wanna make a page that you can click a thumb, view the image but also click NEXT or PREVIOUS. The only way I know of this is if I use a WHERE id=(id+1) type thing. but these arent always going to be consecitive for that user. How can I make it so it views the NEXT one thats viewed under ORDERING (ordering is sometimes blank too) Main SQL for the initial listing: $query="SELECT * FROM gallery_images WHERE category = '$cat' AND owner = '$usern' ORDER BY ordering DESC LIMIT $offset, $limit";