-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdvanced_Regestration.php
45 lines (33 loc) · 996 Bytes
/
Advanced_Regestration.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
<?php
$errors = [];
$data = [];
$string = "";
$Rday = $_POST['Rday'];
if (!empty($Rday)) {
if ($string != "") {
$string = $string . "AND ";
}
$string = $string . "res_date = '" . $Rday . "'";
}
if ($string != "") {
$string = "WHERE " . $string;
}
$connection = mysqli_connect('localhost', 'root', '', 'car_rental_system');
$query = mysqli_query($connection, "SELECT * FROM reservation ".$string);
$num_rows = mysqli_num_rows($query);
$i = 0;
if ($num_rows != 0) {
while ($row = mysqli_fetch_assoc($query)) {
$response[$i]['id'] = $row['res_id'];
$response[$i]['cs'] = $row['customer_id'];
$response[$i]['cr'] = $row['car_id'];
$response[$i]['rd'] = $row['res_date'];
$response[$i]['p'] = $row['pick_date'];
$response[$i]['r'] = $row['return_date'];
$response[$i]['d'] = $row['duration'];
$data[$i] = $response[$i];
$i += 1;
}
}
mysqli_close($connection);
echo json_encode($data);