-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
73 lines (65 loc) · 2.43 KB
/
api.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
63
64
65
66
67
68
69
70
71
72
73
<?php
header('Content-Type:application/json');
if (isset($_GET['table']) && $_GET['table']!="") {
include('db.php');
$conn = new mysqli($servername, $username, $password, $database);
$dbdata = array();
$id = $_GET['table'];
$result = mysqli_query(
$conn,
"SELECT * FROM {$_GET['table']}");
if(mysqli_num_rows($result)>0){
while($row = mysqli_fetch_array($result)){
$dbdata[]=$row;
$id = $row['id'];
$customer_no = $row['customer_no'];
$estimate_no = $row['estimate_no'];
$sales_order = $row['sales_order'];
$production = $row['production'];
$amount_of_doors = $row['amount_of_doors'];
$amount_of_trim = $row['amount_of_trim'];
$address = $row['address'];
$notes = $row['notes'];
$contact = $row['contact'];
$time = $row['time'];
$initials = $row['initials'];
$confirmation = $row['confirmation'];
$created_by = $row['created_by'];
$submit_time = $row['submit_time'];
$edited_by = $row['edited_by'];
$edit_time = $row['edit_time'];
$open = $row['open'];
$canceled = $row['canceled'];
response($id, $customer_no, $estimate_no, $sales_order, $production, $amount_of_doors, $amount_of_trim, $address, $notes, $contact, $time, $initials, $confirmation,
$created_by, $submit_time, $edited_by, $edit_time, $open, $canceled);
};echo json_encode($dbdata);
}else{
response(NULL, NULL, 200,"No Record Found");
}
}else{
response(NULL, NULL, 400,"Invalid Request");
}
function response($id, $customer_no, $estimate_no, $sales_order, $production, $amount_of_doors, $amount_of_trim, $address, $notes, $contact, $time, $initials, $confirmation,
$created_by, $submit_time, $edited_by, $edit_time, $open, $canceled){
$response['id'] = $id;
$response['customer_no'] = $customer_no;
$response['estimate_no'] = $estimate_no;
$response['sales_order'] = $sales_order;
$response['production'] = $production;
$response['amount_of_doors'] = $amount_of_doors;
$response['amount_of_trim'] = $amount_of_trim;
$response['address'] = $address;
$response['notes'] = $notes;
$response['contact'] = $contact;
$response['time'] = $time;
$response['initials'] = $initials;
$response['confirmation'] = $confirmation;
$response['created_by'] = $created_by;
$response['submit_time'] = $submit_time;
$response['edited_by'] = $edited_by;
$response['edit_time'] = $edit_time;
$response['open'] = $open;
$response['canceled'] = $canceled;
$json_response = json_encode($response);
}
?>