/**Pagination test starts*/
// {{{ Initial paging object
$pager = new pager();
/**将 select id,name,age from test where age>20 order by id desc 拆分*/
$sqlArr = array('conn' => $conn, // Database link
'fields' => " id, name,age ", // Main query statement
'table' => "test", // Table name
'condition' => " age>20 ", // Query condition
' order' => " order by id desc " // Sorting method
);
if (!$pager->listn($sqlArr,10,$page)) // Display 10 items per page
{
$pager->errno = 10;
die($pager->errmsg());
}
//}}}
// {{{ Data display
for( $i = 0; $i < count($pager->result); $i++)
{
$tmp = $pager->result[$ i];
echo " id:".$tmp['ID']."
";
echo " name:".$tmp['NAME']."
" ;
echo " age:".$tmp['AGE']."
"
}
// }}}
// {{{ Show page turning Link
echo $pager->page. " / ".$pager->totalpage." Total ".$pager->total. " records";
if ($pager-> prev != 0)
echo "
prev.">Previous page ";
else
echo " Previous page";
if ($pager->next != 0)
echo "
next."> ;Next page ";
else
echo " Next page";
// }}}
?>