1) && ($_GET[page] <= $pages)) { $currentpage = $_GET[page];} // validates page= info $currentimage = 1; if($currentpage > 1) { $currentimage = (($thumbrows * $thumbcolumns * ($currentpage -1))+1); // finds start image for given page. echo 'Previous ' ; } else{ echo 'Previous ' ;} if($currentpage < $pages){echo 'Next';} else{ echo 'Next';} } function displaythubmbnails() { global $thumbcolumns, $thumbrows, $lastimagevalue, $thumbborder, $thumbpadding, $maxthumbdimension; $pages = ceil($lastimagevalue / ($thumbrows * $thumbcolumns)); if ( is_numeric($_GET['page']) && $_GET['page'] > 1 && $_GET['page'] <= $pages ) $currentpage = $_GET['page']; else $currentpage = 1; if ( $currentpage > 1 ) { $currentimage = (($thumbrows * $thumbcolumns * ($currentpage - 1)) + 1 ); echo "Next"; } else echo "Previous"; if ( $currentpage < $pages ) echo .... else.... /* or.. if ( is_numeric($_GET['page']) && $_GET['page'] > 1 && $_GET['page'] <= $pages) ) { $currentpage = $_GET['page']; } else { ... } */ }