"; for ($i=1; $i <= $numPieces; $i++) { // if this is the current image, don't make it a link if ($i == $currImageNum) echo "
  • $currImageNum
  • "; // otherwise, make a link to the image else echo "
  • $i
  • "; } // put image here echo "

    "; // set path to html file containing the caption for this image $currFilePath = sprintf("%s/%d.htm",$dir,$currImageNum); // dump caption content here readfile($currFilePath); // set value for previous image, but don't look for // images before the first image $prevImageNum = $currImageNum - 1; if ($prevImageNum == 0) $prevImageNum = $numPieces; // set value for nest image, but don't look for // images beyond the last image $nextImageNum = $currImageNum + 1; if ($nextImageNum> $numPieces) $nextImageNum = 1; // create previous and next buttons echo "
    "; ?>