-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_books.php
33 lines (27 loc) · 961 Bytes
/
get_books.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
<?php
include 'connect.php';
header('Content-type: application/json');
// FILE UNTUK MENDAPATKAN SEMUA KITAB DARI DB
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
// Ambil info dari Ajax
$id_group = $_GET['id_group'];
// SQL untuk ambil Maximum dari Pasal Tiap Kitab dan Nama Kitab
$sql = "SELECT MAX(pasal) AS total_bab,
kitab
FROM isi_alkitab
GROUP BY kitab
ORDER BY id";
$stmt = $pdo->prepare($sql);
$stmt->execute();
if ($stmt) {
$output = '<option value="" hidden>Kitab</option>';
while ($row = $stmt->fetch()) {
$output .= '<option data-max="' . $row['total_bab'] . '"
value="' . $row['kitab'] . '">' .
ucwords($row['kitab']) .
'</option>';
}
}
$notif = '';
echo json_encode(array('output' => $output, 'notif' => $notif, 'id_group' => $id_group));
}