-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewalldatapost.php
More file actions
executable file
·64 lines (64 loc) · 2.22 KB
/
Copy pathviewalldatapost.php
File metadata and controls
executable file
·64 lines (64 loc) · 2.22 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
58
59
60
61
62
63
64
<!DOCTYPE html>
<html>
<head>
<title> </title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="asset/css/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="asset/css/bootstrap.min.css"/>
<script type="text/javascript" src="asset/js/bootstrap.js"></script>
</head>
<body>
<div class="container">
<?php
// Establish Connection to the Database
$con = mysqli_connect("localhost","root","123","app_login");//Records per page
$per_page=5;
if (isset($_GET["page"])) {
$page = $_GET["page"];
}
else {
$page=1;
}
// Page will start from 0 and Multiple by Per Page
$start_from = ($page-1) * $per_page;
//Selecting the data from table but with limit
$query = "SELECT * FROM tb_information LIMIT $start_from, $per_page";
$result = mysqli_query ($con, $query);
?>
<table class="table table-striped">
<tr><th>ID</th><th>Title</th><th>Text body</th><th>Category</th><th>Action</th></tr>
<?php
while ($row = mysqli_fetch_assoc($result)) {
$id=$row["id"];
?>
<tr>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row["title"]; ?></td>
<td><?php echo $row['text_user']; ?></td>
<td><?php echo $row['category']; ?></td>
<?php echo "<td ><a href=\"delete_pagepost.php?user_id=".$id . "\" onclick=\"return confirm('Are you sure you want to delete datas?');\"><i class='glyphicon glyphicon-trash'></i></a> <a href=\"edit_data_post.php?user_id=".$id . "\" onclick=\"return confirm('Are you sure you want to edit datas?');\"><i class='glyphicon glyphicon-edit'></i></a></td>"?>
</tr>
<?php
};
?>
</table>
<div>
<?php
//Now select all from table
$query = "select * from tb_information";
$result = mysqli_query($con,$query);
// Count the total records
$total_records = mysqli_num_rows($result);
//Using ceil function to divide the total records on per page
$total_pages = ceil($total_records / $per_page);
//Going to first page
echo "<center><a href='viewalldatapost.php?page=1'>".'<span class="glyphicon glyphicon-fast-backward">'."</a> ";
for ($i=1; $i<=$total_pages; $i++){
echo "<a href='viewalldatapost.php?page=".$i."'>".$i."</a> ";
};
// Going to last page
echo "<a href='viewalldatapost.php?page=$total_pages'>".'<span class="glyphicon glyphicon-fast-forward"></span>'."</a></center>";
?>
</div>
</body>
</html>