-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgetAlamat.php
More file actions
37 lines (30 loc) · 837 Bytes
/
getAlamat.php
File metadata and controls
37 lines (30 loc) · 837 Bytes
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
<?php
include_once('koneksi.php');
if (!empty($_GET['customer_id'])) {
$customer_id = $_GET['customer_id'];
$query = "SELECT * FROM alamat WHERE customer_id = '$customer_id'";
} else if (!empty($_GET['id'])) {
$id = $_GET['id'];
$query = "SELECT * FROM alamat WHERE id = '$id'";
} else {
$query = "SELECT * FROM alamat";
}
$get = pg_query($connect, $query);
$data = array();
if (pg_num_rows($get) > 0) {
while ($row = pg_fetch_assoc($get)) {
$data[] = $row;
}
set_response(true, "Data alamat ditemukan", $data);
} else {
set_response(false, "Data alamat tidak ditemukan", $data);
}
function set_response($isSuccess, $message, $data)
{
$result = array(
'isSuccess' => $isSuccess,
'message' => $message,
'data' => $data
);
echo json_encode($result);
}