Code:
<?php
##### Pagination Example (Not Tested, but should work) #####
$page = $_GET['page']; //request and assign the page variable
$max = 20; //how many results per page
$start = ($page * $max);
$count_results = mysql_query("SELECT * FROM `links` ORDER BY id DESC"); // Get data from database
$count_total = mysql_num_rows($count_results); // Count lines in database
$total_pages = ceil($count_total / $max); // Total results divided by max to display
if($page > 1) { // Is the page # more than one?
$prev = ($page - 1); // If yes, take one away from current page
$prevTxt = '<a href="?page='.$prev.'"><<Previous</a>';
}
$nav = ' ';
for($i == 1; $i <= $total_pages; $i++) // For each page number
if($page == $i) { // If page = current page
$nav .= '<b>'.$i.'</b>'; // Echo page in bold
} else {
$nav .= ' <a href="?page='.$i.'">'.$i.'</a> '; // Echo link to the page
}
if($page < $total_pages) { // Is there another page?
$next = ($page + 1); // If so, add 1 to current page
$nextTxt = '<a href="?page='.$next.'">Next>></a>'; // Echo next page link
}
##### End Pagination and Start Displaying the page #####
$info = mysql_query("SELECT * FROM `links` ORDER BY id DESC LIMIT $start, $max"); // Get data from database and limit to the max results
while ($qry = mysql_fetch_array($info)) {
$link = $qry['link'];
echo '<div>'.$link.'</div> <br>';
}
echo 'Pages: '.$prevTxt . $nav . $nextTxt; //display the page links
?>
That will produce anything that is extracted from the sql for that page. You may want to play around with it a little bit, but the script should work with very little modification.
Hope this helps.
Bookmarks