-
Notifications
You must be signed in to change notification settings - Fork 0
/
paging.php
94 lines (76 loc) · 2.58 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?php
include('dbcon.php');
include ('paginate1.php');
$per_page = 5;
$result = mysql_query("SELECT * FROM slogin");
$total_results = mysql_num_rows($result);
$total_pages = ceil($total_results / $per_page);
if (isset($_GET['page'])) {
$show_page = $_GET['page'];
if ($show_page > 0 && $show_page <= $total_pages) {
$start = ($show_page - 1) * $per_page;
$end = $start + $per_page;
} else {
$start = 0;
$end = $per_page;
}
} else {
$start = 0;
$end = $per_page;
}
// display pagination
$page = intval($_GET['page']);
$tpages=$total_pages;
if ($page <= 0)
$page = 1;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Database</title>
<h3 align="center"> Student Database </h3>
<link rel="stylesheet" type="text/css" href="new.css" />
<style type="text/css">
.logo
{
text-align: center;
}
.container{
}
</style>
</head>
<body>
<a align='left' href="index.php"> HOME </a>
<div class="container">
<div class="row">
<div class="span6 offset3">
<div class="mini-layout">
<?php
$reload = $_SERVER['PHP_SELF'] . "?tpages=" . $tpages;
echo '<div class="pagination"><ul>';
if ($total_pages > 1) {
echo paginate($reload, $show_page, $total_pages);
}
echo "</ul></div>";
echo "<table class='table table-bordered'>";
echo "<thead><tr><th>Name</th> <th>Email</th> </tr></thead>";
for ($i = $start; $i < $end; $i++) {
if ($i == $total_results) {
break;
}
// echo out the contents of each row into a table
echo "<tr " . $cls . ">";
echo '<td>' . mysql_result($result, $i, 'name') . '</td>';
echo '<td>' . mysql_result($result, $i, 'email') . '</td>';
echo "</tr>";
}
echo "</table>";
?>
</div>
</div>
</div>
</div>
</body>
</html>