the detail page uses a querystring variable to determine which record to show, for example:
details?ID=10
you can use simple math to create a link to the next or previous images using the querystring variable:
<?php if(isset($_GET['ID'])) { ?><a href="details.php?ID=<?php echo($_GET['ID'] - 1);?>">Previous</a> <a href="details.php?ID=<?php echo($_GET['ID'] + 1);?>">Next</a><?php } ?>
couple of issue to be aware of though:
1) If the ID is the previous link will point to 0 which will load a no record found page.
2) If you delete images, there may be a break in id values, so you may get an occasional no record found page in the middle.
3) once you get to the last image, the next link will point to an id that does not exist.