-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilterBycar.php
110 lines (78 loc) · 2.04 KB
/
filterBycar.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
$data = [];
$i = 0;
$string = "";
$year = $_POST['year'];
$color = $_POST['color'];
$model = $_POST['model'];
$status = $_POST['status'];
$louza = $_POST['louza'];
$start =$_POST['start'];
$end =$_POST['end'];
if(!empty($start)&& !empty($end)){
if($string != ""){
$string = $string."AND ";
}
$string = $string."res_date >= '" . $start . "'AND res_date <= '" . $end . "'";
}
if(!empty($year)){
if($string != ""){
$string = $string."AND ";
}
$string = $string."year= '" . $year . "'";
}
if(!empty($color)){
if($string != ""){
$string = $string."AND ";
}
$string = $string."color= '" . $color . "'";
}
if(!empty($model)){
if($string != ""){
$string = $string."AND ";
}
$string = $string."model= '" . $model . "'";
}
if(!empty($status)){
if($string != ""){
$string = $string."AND ";
}
$string = $string."status= '" . $status . "'";
}
if(!empty($louza)){
if($string != ""){
$string = $string."AND ";
}
$string = $string."car_id= '" . $louza . "'";
}
if($string != ""){
$string = "WHERE ".$string;
}
$connection = mysqli_connect('localhost','root','','car_rental_system');
if (!$connection){ return; }
$sql = "SELECT * FROM `report3` $string ";
$query = mysqli_query($connection,$sql);
$num_rows = mysqli_num_rows($query);
if($num_rows!=0)
{
while($row=mysqli_fetch_assoc($query))
{
$response[$i]['rid'] = $row['res_id'];
$response[$i]['cid'] = $row['customer_id'];
$response[$i]['res'] = $row['res_date'];
$response[$i]['pick'] = $row['pick_date'];
$response[$i]['return'] = $row['return_date'];
$response[$i]['id'] = $row['car_id'];
$response[$i]['m'] = $row['model'];
$response[$i]['y'] = $row['year'];
$response[$i]['c'] = $row['color'];
$response[$i]['s'] = $row['status'];
$response[$i]['o'] = $row['off_id'];
$response[$i]['p'] = $row['price_per_day'];
$data[$i] = $response[$i];
$i +=1;
}
session_start();
}
mysqli_close($connection);
echo json_encode($data);