Does anyone have a php next previous button tutorial they are willing to post?
Printable View
Does anyone have a php next previous button tutorial they are willing to post?
What is there to make a tutorial about? You limit the amount of data you fetch and keep track of the page you're on (best with a GET parameter). For example, a DB supporting the common LIMIT .. OFFSET SQL extension can be made to fetch just a subset of the rows like this:
Code:$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$r = query('SELECT COUNT(*) FROM tablename WHERE criteria');
$total = fetch($r, 1);
$r = query('SELECT fields FROM tablename WHERE criteria LIMIT ? OFFSET ?',
$rowsPerPage, ($page - 1) * $rowsPerPage);
// Output $r
if($page > 1) {
// Output previous link
}
if($page * $rowsPerPage < $total) {
// Output next link
}
http://www.vbforums.com/showthread.p...51#post1988751Quote:
Originally Posted by dreamerd