//function to return the pagination string function getPaginationString($page = 1, $totalitems, $limit = 15, $adjacents = 1, $targetpage = "/", $pagestring = "?page=") { //defaults if(!$adjacents) $adjacents = 1; if(!$limit) $limit = 15; if(!$page) $page = 1; if(!$targetpage) $targetpage = "/"; //other vars $prev = $page - 1; //previous page is page - 1 $next = $page + 1; //next page is page + 1 $lastpage = ceil($totalitems / $limit); //lastpage is = total items / items per page, rounded up. $lpm1 = $lastpage - 1; //last page minus 1 /* Now we apply our rules and draw the pagination object. We're actually saving the code to a variable in case we want to draw it more than once. */ $pagination = ""; if($lastpage > 1) { $pagination .= "