forked from hieu2505/restaurant
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpagination.php
More file actions
57 lines (53 loc) · 1.39 KB
/
Copy pathpagination.php
File metadata and controls
57 lines (53 loc) · 1.39 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
#pagination{
text-align: center;
}
</style>
<body>
<div id="pagination">
<?php
if ($current_page > 3) {
$first_page = 1;
?>
<a class="page-item" href="?per_page=<?= $item_per_page ?>&page=<?= $first_page ?>">First</a>
<?php
}
if ($current_page > 1) {
$prev_page = $current_page - 1;
?>
<a class="page-item" href="?per_page=<?= $item_per_page ?>&page=<?= $prev_page ?>">Prev</a>
<?php }
?>
<?php for ($num = 1; $num <= $totalPages; $num++) { ?>
<?php if ($num != $current_page) { ?>
<?php if ($num > $current_page - 3 && $num < $current_page + 3) { ?>
<a class="page-item" href="?per_page=<?= $item_per_page ?>&page=<?= $num ?>"><?= $num ?></a>
<?php } ?>
<?php } else { ?>
<strong class="current-page page-item"><?= $num ?></strong>
<?php } ?>
<?php } ?>
<?php
if ($current_page < $totalPages - 1) {
$next_page = $current_page + 1;
?>
<a class="page-item" href="?per_page=<?= $item_per_page ?>&page=<?= $next_page ?>">Next</a>
<?php
}
if ($current_page < $totalPages - 3) {
$end_page = $totalPages;
?>
<a class="page-item" href="?per_page=<?= $item_per_page ?>&page=<?= $end_page ?>">Last</a>
<?php
}
?>
</div>
</body>
</html>