PHP Simple Digital Paging display code
$totalpages) {//Set current page to the last page $currentpage = $totalpages;}//End if//If current page was less than First Page...if ($currentpage < 1) {//Set current page to first page $currentpage = 1;}//End if//The offset of The list, based on current page $offset = ($currentpage-1) * $rowsperpage;//Get the info from the db/* $sql = "Select ID, number from numbers LIMIT $offset, $rowsperpage "; $result = mysql_query ($sql, $conn) or Trigger_error (" SQL ", E_user_err OR); */$sql = "SELECT id, number from numbers LIMIT $offset, $rowsperpage"; Echo $sql. "
";//While there is rows to be fetched.../*while ($list = Mysql_fetch_assoc ($result)) {//Echo data echo $list [' ID '] . " : " . $list [' Number ']. "
";} End while*//****** Build the pagination links ******///range of num links to Show$range = 3;//if not on page 1, Don ' T show back Linksif ($currentpage > 1) {//Show << link to go back to Page 1 echo "<<"; Get previous page num $prevpage = $currentpage-1; Show < link to go 1 page echo "<";} End If//loop to show links to range of pages around current pagefor ($x = ($currentpage-$range); $x < ($current Page + $range) + 1); $x + +) {//If it ' s a valid page number ... if (($x > 0) && ($x <= $totalpages)) {//If we ' re on cur Rent page ... if ($x = = $currentpage) {//' highlight ' it but don ' t make a link echo "[$x] "; If not current page ...} else {//Make it a link echo "$x"; }//End else}//End If}//end for//if not on last page, show forward and last page links I F ($currentpage! = $totalpages) {//Get next page $nextpage = $currentpage + 1; echo forward link for next page echo ">"; echo forward link for lastpage echo ">>";} End if/****** End Build pagination links ******/?>
<title>Page out</title>Excerpt from: http://www.phpfreaks.com/tutorial/basic-pagination