rough and ready........something like this should work...

$pagesize = 20;
$page = $page ? $page : 1;
$pages = ceil(mysql_num_rows( $results ) / $pagesize );
mysql_data_seek( $results, ($page - 1) * $pagesize );

while( ($row = mysql_fetch_object( $results )) && ( $counter++ <
$pagesize) )
{
//      print rows of data etc etc
}

if( ($page > 1) )
{
        print "<a href=?page=".($page + 1).">Next</a>";
}

if( ($page < $pages) && ( $pages > 1 )  )
{
        print "<a href=?page=".($page + 1).">Next</a>";
}






-----Original Message-----
From: Pranot Kokate [mailto:[EMAIL PROTECTED]]
Sent: 16 July 2001 09:40
To: [EMAIL PROTECTED]
Subject: [PHP-DB] NEXT - PREVIOUS coding


hi.. friends

i have a database (mysql) in which their r many records. Through PHP i want
them to display on the page.

Main requirement is that there should be a NEXT - PREVIOUS facility. So if
there r 20 records and suppose only 10 should show up on scren at a time,
then a NEXT link should be visible which could show the remaining 10
records.

Their can be n no. of records.

Pls help.

Kind Regards,
Pranot


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to