How to Display records page by page ? or how to do pagination using php and my sql

<?php
include(‘includes/database.php’); //this is to execute the query

/**
* @author ["Arun Raj R , Software Engineer "]
* @copyright 2008
*/

if (isset($_REQUEST['page']))
{
$page = $_REQUEST['page'];
if($page==” || $page<1)
$page=1;
}
else
{
$page=1;
}
$start_from =($page-1) * 10;
$rs_result = QryExecute(“SELECT * FROM table_usp ORDER BY id DESC LIMIT $start_from,10″);
while ($row = mysql_fetch_assoc($rs_result)) {

echo $row['id'];
echo $row['name'];

}

?>

I think it may helpful to you . If you have any suggestions or questios pls reply here

or u can use this code

<?php
include(‘includes/database.php’);
$page = 0;
if(isset($_REQUEST['page']))
{
  if(intval($_REQUEST['page'])==$_REQUEST['page'])
  {
    $page = $_REQUEST['page'];
  }
}
define(‘RESULTS’,10);

$start = $page*RESULTS;
$sql = ‘SELECT * FROM table_up ORDER BY id DESC LIMIT ‘.$start.’,’.RESULTS;
$rs = QryExecute($sql);
while($obj = mysql_fetch_object($rs))
{
echo ‘<pre>’;
print_r($obj);
echo ‘</pre>’;
}
?>

About

me : yeay its me arun

Tagged with: , , ,
Posted in Misk

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>