- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
public function getPagination($page, $rows, $limit){
$pageArray = array();
if ($rows > $limit){
$allPage = ceil($rows/$limit);
if ($allPage <= 7){
for ($i=1;$i<=$allPage;$i++){$pageArray[]=$i;}
}else{
if ($page < 5){
for ($i=1;$i<=($page+3);$i++){$pageArray[]=$i;}
$pageArray[]=$allPage;
}else{
if ($allPage <= ($page+3)){
$pageArray[]=1;
for ($i=($page-3);$i<=$allPage;$i++){$pageArray[]=$i;}
}else{
$pageArray[]=1;
for ($i=($page-3);$i<=($page+3);$i++){$pageArray[]=$i;}
$pageArray[]=$allPage;
}
}
}
return array(
'pages' => $pageArray,
'page' => $page
);
}else{
return array(
'pages' => 1,
'page' => $page
);
}
}
My friend wrote pagination function. takes current page, number of rows (from query), and limit on each page. function works really good but :D govno kod :D