How to Display records page by page ? or how to do pagination using php and my sql
Wednesday, February 20, 2008 3:22:17 PM
<?php
include('includes/database.php'); //this is to execute the query, if you want the sourcecode pls click
/**
* @author ["Arun Raj R , Software Engineer ,Ventures Unlimited Solutions"]
* @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














Marcinsuperlolek # Thursday, February 28, 2008 10:16:03 PM
<?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>'; } ?>and here is description:
first of all i prefer using, 0 as the start point, this is normall and all arrays, and other things usually start from 0 so from programmist point of view it's normal, second thing, it's better to use intval(), to get integer from value
and the last thing, but not least, there is a difference between single and double quotes,
with double quotes, php parses the string to find any user defined variable, while with single quotes, php doesn't do that, so the code execution with huge strings, is much faster...
Arun Raj RArunRaj # Monday, March 3, 2008 5:40:49 PM
I would like to be ur student.
because im really new in this PHP MYSQL domain.
really i like php