-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviewbiodata.php
More file actions
194 lines (158 loc) · 5.04 KB
/
viewbiodata.php
File metadata and controls
194 lines (158 loc) · 5.04 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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
<?php
session_start();
if(!isset($_SESSION["user"]))
{
echo "<script>alert('Session anda belum terdaftar, silakan login kembali'); document.location='login.php';</script>";
}else
{
?>
<!DOCTYPE html>
<html>
<title>TUGAS PIL</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="asset/css/w3.css">
<style>
body {
background-color: #FFECD1;
}
.w3-button {
background-color: #0B3954;
color: white;
padding: 11px 40px;
border-radius: 6px;
transition: 0.3s;
}
</style>
<body>
<!-- Navbar (sit on top) -->
<div class="w3-top">
<div class="w3-bar w3-orange w3-wide w3-padding w3-card">
<a href="dashboard.php" class="w3-bar-item w3-orange w3-button">Back to Dashboard</a>
<a href="logout.php" class="w3-bar-item w3-button w3-right">LogOut</a>
</div>
</div>
<!-- Page content -->
<div class="w3-content w3-padding" style="max-width:1564px">
<!-- Contact Section -->
<div class="w3-container w3-padding-32" id="contact">
<h3 class="w3-border-bottom w3-border-light-grey w3-padding-16">Daftar Biodata</h3>
<!-- <a href="dashboard.php" class="w3-button w3-border w3-gray">Back</a> -->
<div class="w3-row">
<table class="w3-table-all">
<thead>
<tr class="w3-orange">
<th>NAMA</th>
<th>PHONE</th>
<th>EMAIL</th>
<th>FOTO</th>
<th>GENDER</th>
<th>AKSI</th>
</tr>
</thead>
<?php
include "config/koneksi.php";
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 10;
$offset = ($pageno-1) * $no_of_records_per_page;
$total_pages_sql = "SELECT COUNT(*) FROM biodata";
$result = mysqli_query($conn,$total_pages_sql);
$total_rows = mysqli_fetch_array($result)[0];
$total_pages = ceil($total_rows / $no_of_records_per_page);
$sql = "SELECT * FROM biodata LIMIT $offset, $no_of_records_per_page";
$res_data = mysqli_query($conn,$sql);
if(mysqli_num_rows($res_data) > 0)
{
while($row = mysqli_fetch_array($res_data)){
?>
<tr>
<td><?php echo $row["nama"];?></td>
<td><?php echo $row["phone"];?></td>
<td><?php echo $row["email"];?></td>
<td><?php echo $row["foto"];?></td>
<td><?php echo $row["gender"];?></td>
<td><a href="javascript:void(0)" class="w3-button w3-tiny" onClick="deleteid(<?php echo $row['id'];?>,window.location.href)">Hapus</button></td>
</tr>
<?php
};
} else { ?>
<tr>
<td colspan ="6"><p align ="center">No Data</p></td>
</tr>
<?php
}
?>
</table>
<?php $conn->close(); ?>
<div class="w3-bar w3-border ">
<?php
$pagLink = "";
if ($pageno >=2 ) {?>
<a class='w3-bar-item w3-button ' href='<?php echo "viewbiodata.php?pageno=".($pageno-1); ?>' >«</a>
<?php
} else if ($pageno == 1)
{?>
<a href="#" class="w3-bar-item w3-button w3-white" disabled>«</a>
<?php } ?>
<?php
for ($i=1; $i<=$total_pages; $i++) {
if ($i == $pageno) {
$pagLink .= "<a class='w3-bar-item w3-button' href='viewbiodata.php?pageno=".$i."'>".$i." </a>";
}
else {
$pagLink .= "<a class='w3-bar-item w3-button w3-white' href='viewbiodata.php?pageno=".$i."'>".$i." </a>";
}
};
echo $pagLink;
if($pageno < $total_pages){ ?>
<a class='w3-bar-item w3-button' href='<?php echo "viewbiodata.php?pageno=".($pageno+1);?>'>»</a>
<?php } else {
?>
<a href="#" class="w3-bar-item w3-button ">»</a>
<?php } ?>
</div>
</div>
</div>
<!-- End page content -->
</div>
<!-- Footer -->
<footer class="w3-bottom w3-center w3-#FFECD1 w3-padding-5">
<p>Powered by <a href="Eror.php" title="W3.CSS" target="_blank" class="w3-hover-text-blue">Amat</a></p>
</footer>
<script>
function deleteid(id,url) {
if( id != "" ){
if (confirm('Are you sure you want to delete '+id+' this thing into the database?')) {
var xhttp;
xhttp = new XMLHttpRequest();
xhttp.open("POST", "deletebiodata.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("id="+id);
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var data = this.responseText;
if (data == "true" ){
alert("Hapus Data Berhasil");
setTimeout(function(){
window.location.assign(url); }, 100);
} else if (data == "false"){
alert("Hapus Data Tidak Berhasil");
}
}
};
} else {
setTimeout(function(){
window.location.assign(url); }, 100);
}
}
}
</script>
</body>
</html>
<?php
};
?>