Assuming your logic for showing a photo is something like below in the URL
gallery.php?show_photo=99
and that you're using mysql; you can create a new table, with the columns for the comments, and a column like "show_photo_id" to relate the comment(s) to the photo(s) via the 'show_photo' value.
then when displaying the comments (via SELECT .. WHERE show_photo_id = $_GET['show_photo']) search 'php pagination' for how to put it in pages