-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_fetch_ketua.php
62 lines (53 loc) · 1.87 KB
/
admin_fetch_ketua.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
include 'connect.php';
header('Content-type: application/json');
// FILE UNTUK RESPONSE PENGAMBILAN DATA KETUA DARI DB
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
// Ambil email, nama, no hp, umur, status ketua, dan apakah group member
$sql = "SELECT email,
nama,
hp,
FLOOR(DATEDIFF(NOW(),lahir)/365.25) as umur ,
ketua,
group_member
FROM user
WHERE ketua = 1 AND email != 'admin@gmail.com' ";
$stmt = $pdo->prepare($sql);
$stmt->execute();
// isi DataTable
$output =
'<thead>
<tr>
<th><b>No</b></th>
<th><b>Email</b></th>
<th><b>Nama</b></th>
<th><b>No HP</b></th>
<th><b>Action</b></th>
<th><b>Detail</b></th>
</tr>
</thead>';
$output .= '<tbody>';
$count = 0;
$detail_button = '<div class="container">
<div class="row">
<input type="submit" role="button" class="btn btn-info see-detail" href="#detail" data-bs-toggle="modal" value="See Detail">
</div>
</div>';
while($row = $stmt->fetch()){
$button = '<div class="container">
<div class="row">
<input type="submit" class="btn btn-primary assign-group btn-block" data-email="' . $row['email'] . '" value="Assign Group">
</div>
</div> ';
$output .= '<tr>
<td>'. ++$count .'</td>
<td>'. $row['email'] .'</td>
<td>'. $row['nama'] .'</td>
<td>'. $row['hp'] .'</td>
<td>'. $button .'</td>
<td>'. $detail_button .'</td>
</tr>';
}
$output .= '</tbody>';
echo json_encode(array('output' => $output));
}