-
Notifications
You must be signed in to change notification settings - Fork 0
/
paging.php
62 lines (50 loc) · 1.45 KB
/
paging.php
1
2
3
4
5
6
7
8
9
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
echo "<ul class='pagination pull-left margin-zero mt0'>";
// first page button will be here
// first page button
if($page>1){
$prev_page = $page - 1;
echo "<li>";
echo "<a href='{$page_url}page={$prev_page}'>";
echo "<span style='margin:0 .5em;'>«</span>";
echo "</a>";
echo "</li>";
}
// clickable page numbers will be here
// clickable page numbers
// find out total pages
$total_pages = ceil($total_rows / $records_per_page);
// range of num links to show
$range = 1;
// display links to 'range of pages' around 'current page'
$initial_num = $page - $range;
$condition_limit_num = ($page + $range) + 1;
for ($x=$initial_num; $x<$condition_limit_num; $x++) {
// be sure '$x is greater than 0' AND 'less than or equal to the $total_pages'
if (($x > 0) && ($x <= $total_pages)) {
// current page
if ($x == $page) {
echo "<li class='active'>";
echo "<a href='javascript::void();'>{$x}</a>";
echo "</li>";
}
// not current page
else {
echo "<li>";
echo " <a href='{$page_url}page={$x}'>{$x}</a> ";
echo "</li>";
}
}
}
// last page button will be here
// last page button
if($page<$total_pages){
$next_page = $page + 1;
echo "<li>";
echo "<a href='{$page_url}page={$next_page}'>";
echo "<span style='margin:0 .5em;'>»</span>";
echo "</a>";
echo "</li>";
}
echo "</ul>";
?>