<?
$page=(int)$_GET['page'];
if(empty($page)) $page=1;
$limit=5;
$all=$db->query("select count(*) from `mytable`")->fetchColumn();
$total=ceil($all/$limit);
if($page>$total)$page=1;
$start=$page*$limit-$limit;
if($all==true){
$info=$db->query("select * from `mytable` order by `id` desc limit $start,$limit")->fetchAll(PDO::FETCH_OBJ);
foreach($info as $i){
print("{$i->user}<br/>");
}
if($page>1){
echo "<a href=\"?page=".($page-1)."\">Geri</a>";
}
if($page!=$total){
echo "<a href=\"?page=".($page+1)."\">Ireli</a>";
}
}
?>