-
Notifications
You must be signed in to change notification settings - Fork 0
/
cars.php
358 lines (337 loc) · 11.1 KB
/
cars.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<?php
session_start();
// No login required
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<title>Car Research</title>
<meta content="" name="description">
<meta content="" name="keywords">
<?php
require('./admin/db.php');
require('header2.php');
?>
<body>
<?php require('./menu.php'); ?>
<main id="main" class="main">
<div class="pagetitle">
<h1>Car Research</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item">Home</li>
<li class="breadcrumb-item">Research</li>
<li class="breadcrumb-item active">Car Research</li>
</ol>
</nav>
</div><!-- End Page Title -->
<!---cdb code begin-->
<h1 align="center"><i class="bi bi-search"></i> Car Research</h1>
<p align=center>Fine-tune your search using one or more filters</p>
<center>
<form action="#" method="post">
<table cellpadding="5px" align="center">
<tr>
<th>Make</th>
<th>Price</th>
<th>Type</th>
<th>Mileage (kmpl)</th>
<th>Transmission</th>
<th>Fuel</th>
<th>Seats</th>
</tr>
<tr>
<td>
<select name="make" id="make">
<option value="">All</option>
<?php
$sel_query="Select DISTINCT(Make) from specs;";
$result = mysqli_query($con, $sel_query);
while($row = mysqli_fetch_assoc($result)) { ?>
<option value="<?php echo $row["Make"]; ?>"><?php echo $row["Make"]; ?></option><?php } ?>
</select>
</td>
<td>
<select name="price" id="price">
<option value="">All</option>
<?php
$min_query="Select MIN(Ex_showroom_price) from specs;";
$max_query="Select MAX(Ex_showroom_price) from specs;";
$min_result = mysqli_query($con,$min_query);
$min_row = mysqli_fetch_assoc($min_result);
$max_result = mysqli_query($con,$max_query);
$max_row = mysqli_fetch_assoc($max_result);
$analysis = "";
$range = round(($max_row['MAX(Ex_showroom_price)']-$min_row['MIN(Ex_showroom_price)'])/10);
$iter = 10;
//echo $range;
for($i = 1; $i<=$iter;$i++)
{
?>
<option value="<?php echo round($i*$range/100000)*100000; ?>"><?php echo "Below ₹".round($i*$range/100000)." lakh"; ?></option><?php } ?>
</select>
</td>
<td>
<select name="body_type" id="body_type">
<option value="">All</option>
<?php
$sel_query="Select DISTINCT(Body_type) from specs;";
$result = mysqli_query($con,$sel_query);
while($row = mysqli_fetch_assoc($result)) { ?>
<option value="<?php echo $row["Body_type"]; ?>"><?php echo $row["Body_type"]; ?></option><?php } ?>
</select>
</td>
<td>
<select name="mileage" id="mileage">
<option value="">All</option>
<?php
//$sel_query="Select DISTINCT(City_mileage) from specs;";
$sel_query="Select MAX(City_mileage) from specs;";
$result = mysqli_query($con,$sel_query);
$row = mysqli_fetch_assoc($result);
$iter = $row['MAX(City_mileage)']/5 ;
echo $row['MAX(City_mileage)'];
$param = 5;
for($i = 1; $i<$iter;$i++)
{
/* while($row = mysqli_fetch_assoc($result)) { ?>
<option value="<?php echo $row["City_mileage"]; ?>"><?php echo $row["City_mileage"]; ?></option><?php } ?>*/?>
<option value="<?php echo $param*$i; ?>"><?php echo "Above ".$param*$i; ?></option>
<?php
}
?>
</select>
</td>
<td>
<select name="transmission" id="transmission">
<option value="">All</option>
<?php
$sel_query="Select DISTINCT(Transmission) from specs;";
$result = mysqli_query($con,$sel_query);
while($row = mysqli_fetch_assoc($result)) { ?>
<option value="<?php echo $row["Transmission"]; ?>"><?php echo $row["Transmission"]; ?></option><?php } ?>
</select>
</td>
<td>
<select name="fuel" id="fuel">
<option value="">All</option>
<?php
$sel_query="Select DISTINCT(Fuel_type) from specs;";
$result = mysqli_query($con,$sel_query);
while($row = mysqli_fetch_assoc($result)) { ?>
<option value="<?php echo $row["Fuel_type"]; ?>"><?php echo $row["Fuel_type"]; ?></option><?php } ?>
</select>
</td>
<td>
<select name="seating_capacity" id="seating_capacity">
<option value="">All</option>
<?php
$sel_query="Select DISTINCT(Seating_capacity) from specs order by Seating_capacity asc;";
$result = mysqli_query($con,$sel_query);
while($row = mysqli_fetch_assoc($result)) { ?>
<option value="<?php echo $row["Seating_capacity"]; ?>"><?php echo $row["Seating_capacity"]; ?></option><?php } ?>
</select>
</td>
</tr>
</table>
<br><input type="submit" value="Search">
</form>
</center>
<br><br>
<?php //if (isset($_POST['fuel'])) { ?>
<section class="section">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<table class="table datatable">
<thead>
<tr>
<th><strong>S.No</strong></th>
<th><strong>Make</strong></th>
<th><strong>Model</strong></th>
<th><strong>Variant</strong></th>
<th><strong>Price</strong></th>
<!--th><strong>Cylinders</strong></th>
<th><strong>Drivetrain</strong></th>
<th><strong>Engine Location</strong></th>
<th><strong>Fuel Tank Capacity</strong></th-->
<th><strong>Fuel Type</strong></th>
<th><strong>Body Type</strong></th>
<th><strong>City Mileage</strong></th>
<!--th><strong>Gears</strong></th>
<th><strong>Power</strong></th>
<th><strong>Torque</strong></th>
<th><strong>Seating Capacity</strong></th-->
<th><strong>Transmission</strong></th>
<!--th><strong>Boot Space</strong></th-->
</tr>
</thead>
<tbody>
<?php
$count=1;
$sel_query = "Select * from specs";
$flag = 0;
if(isset($_POST['make']))
{
if(strlen($_POST['make'])>0)
{
if($flag == 0)
{
$flag = 1;
$sel_query .= " where Make = '".$_POST['make']."'";
}
else
{
$sel_query .= " and Make = '".$_POST['make']."'";
}
//$analysis .= "Make: ".$_POST['make'];
}
}
if(isset($_POST['price']))
{
if(strlen($_POST['price'])>0)
{
if($flag == 0)
{
$flag = 1;
$sel_query .= " where Ex_showroom_price <= '".$_POST['price']."'";
}
else
{
$sel_query .= " and Ex_showroom_price <= '".$_POST['price']."'";
}
}
}
if(isset($_POST['body_type']))
{
if(strlen($_POST['body_type'])>0)
{
if($flag == 0)
{
$flag = 1;
$sel_query .= " where Body_type = '".$_POST['body_type']."'";
}
else
{
$sel_query .= " and Body_type = '".$_POST['body_type']."'";
}
}
}
if(isset($_POST['mileage']))
{
if(strlen($_POST['mileage'])>0)
{
if($flag == 0)
{
$flag = 1;
$sel_query .= " where City_mileage >= '".$_POST['mileage']."'";
}
else
{
$sel_query .= " and City_mileage >= '".$_POST['mileage']."'";
}
}
}
if(isset($_POST['transmission']))
{
if(strlen($_POST['transmission'])>0)
{
if($flag == 0)
{
$flag = 1;
$sel_query .= " where Transmission = '".$_POST['transmission']."'";
}
else
{
$sel_query .= " and Transmission = '".$_POST['transmission']."'";
}
}
}
if(isset($_POST['fuel']))
{
if(strlen($_POST['fuel'])>0)
{
if($flag == 0)
{
$flag = 1;
$sel_query .= " where Fuel_type = '".$_POST['fuel']."'";
}
else
{
$sel_query .= " and Fuel_type = '".$_POST['fuel']."'";
}
}
}
if(isset($_POST['seating_capacity']))
{
if(strlen($_POST['seating_capacity'])>0)
{
if($flag == 0)
{
$flag = 1;
$sel_query .= " where Seating_capacity = '".$_POST['seating_capacity']."'";
}
else
{
$sel_query .= " and Seating_capacity = '".$_POST['seating_capacity']."'";
}
}
}
$sel_query .= ";";
//echo $sel_query;
$result = mysqli_query($con,$sel_query);
while($row = mysqli_fetch_assoc($result)) { ?>
<tr><td align="center"><?php echo $count; ?></td>
<td align="center"><?php echo $row["Make"]; ?></td>
<td align="center"><?php echo $row["Model"]; ?></td>
<td align="center"><?php echo $row["Variant"]; ?></td>
<td align="center"><?php echo "₹".number_format($row["Ex_showroom_price"]); ?></td>
<!--td align="center"><?php //echo $row["Cylinders"]; ?></td>
<td align="center"><?php //echo $row["Drivetrain"]; ?></td>
<td align="center"><?php //echo $row["Engine_location"]; ?></td>
<td align="center"><?php //echo $row["Fuel_tank_capacity"]; ?></td-->
<td align="center"><?php echo $row["Fuel_type"]; ?></td>
<td align="center"><?php echo $row["Body_type"]; ?></td>
<td align="center"><?php echo $row["City_mileage"]; ?></td>
<!--td align="center"><?php //echo $row["Gears"]; ?></td-->
<!--td align="center"><?php// echo $row["Power"]; ?></td>
<td align="center"><?php //echo $row["Torque"]; ?></td>
<td align="center"><?php //echo $row["Seating_capacity"]; ?></td-->
<td align="center"><?php echo $row["Transmission"]; ?></td>
<!--td align="center"><?php //echo $row["Boot_space"]; ?></td-->
</tr>
<?php $count++; } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section>
<?php //} ?>
<br>
<!--cdb code end-->
</main><!-- End #main -->
<!-- Footer -->
<footer id="footer" class="footer">
<div class="copyright">
© Copyright <strong><span>CarDB</span></strong>. All Rights Reserved
</div>
</footer><!-- End Footer -->
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
<!-- Vendor JS Files -->
<script src="assets/vendor/apexcharts/apexcharts.min.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/chart.js/chart.min.js"></script>
<script src="assets/vendor/echarts/echarts.min.js"></script>
<script src="assets/vendor/quill/quill.min.js"></script>
<script src="assets/vendor/simple-datatables/simple-datatables.js"></script>
<script src="assets/vendor/tinymce/tinymce.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
</body>
</html>