Register Blogs FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

Go Back   DeveloperBarn Forums > Blogs

Sponsored Links

Old

Pagination Tutorial - Part 4

Posted December 13th, 2008 at 11:25 AM by don94403
I have another web site that can access a database that contains 2,100 records of past crew members of my old Navy ship. I wanted to make it convenient to search for personnel who were aboard the ship during any particular year, and I also wanted to be able to search in alphabetic groups. This isn’t the same kind of pagination we’ve been discussing, but it’s another way to display data conveniently for the viewer. Visit usselectra.org and click on the Database button on the left, then select...
don94403's Avatar
Moderator
Posted in PHP , MySQL
Views 64 Comments 0 don94403 is offline
Old

Pagination Tutorial - Part 3

Posted December 13th, 2008 at 11:25 AM by don94403
More complicated pagination:
That’s pretty much it, for simple pagination. Sometimes you may want added features, such as allowing the viewer to sort the results they see. I have a poetry web site that illustrates such a feature. Take a look at The Poa Tree - Home and click on the Go To The Poems button in the upper right. The script for that page follows:

PHP Code:
<?php
session_start
();

if (isset(
$_SESSION['login'])) $login $_SESSION['login'];
if (isset(
$_GET['sort']))
...
don94403's Avatar
Moderator
Posted in PHP , MySQL
Views 36 Comments 0 don94403 is offline
Old

Pagination Tutorial - Part 2

Posted December 13th, 2008 at 11:25 AM by don94403
Updated December 14th, 2008 at 02:06 AM by don94403 (Changed method of determining number of records.)
Simple Example:
This is pretty much the simplest example of a pagination script:

PHP Code:
<?php
// set the page number – if it is not passed in the URL, set it to page 1
if(isset($_GET['pg'])) {
    
$pg=mysql_real_escape_string($_GET['pg']);
} else {
    
$pg=1;
}
if(
$pg 1$pg=1;

$perpage=10;  // <-- set to how many items you want on a page
$startrec=($pg 1) * $perpage;  // <-- starting record for
...
Tags: pagination
don94403's Avatar
Moderator
Posted in PHP , MySQL
Views 49 Comments 0 don94403 is offline
Old

Pagination Tutorial - Part 1

Posted December 13th, 2008 at 11:24 AM by don94403
Updated December 13th, 2008 at 12:57 PM by don94403
A frequent subject of questions in any PHP/MySQL forum is how to display some number of database records on a web page, letting the viewer "page" to the next group, or return to a previous group. This is often called pagination and there are many articles available describing how to write the code to do it. Not wishing to be left out of the ranks of authors who write about it, I have now written my version of a Pagination Tutorial, with example code. I hope that it will be useful to someone....
Tags: pagination
don94403's Avatar
Moderator
Posted in PHP , MySQL
Views 63 Comments 0 don94403 is offline

All times are GMT -4. The time now is 09:18 AM.



Content Relevant URLs by vBSEO 3.2.0