-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearchcar.php
More file actions
135 lines (85 loc) · 2.67 KB
/
searchcar.php
File metadata and controls
135 lines (85 loc) · 2.67 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>About</title>
</head>
<style>
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap");
</style>
<style>
@import url("https://fonts.googleapis.com/css2?family=Work+Sans:wght@500&display=swap");
</style>
<link rel="stylesheet" href="src/style.css" />
<link rel="stylesheet" href="/src/responsive.css" />
<body>
<?php
include 'header.php'
?>
<!-- banner image -->
<div class="banner_wrap">
<div class="banner_container">
<div class="overlay"></div>
<div class="container">
<h1>ABOUT US</h1>
</div>
</div>
</div>
<!-- banner image ends -->
<!-- search button -->
<div class="container_search">
<h2>Car Search</h2>
<form action="searchcar.php" method="POST">
<div>
<label for="model">Model:</label>
<input type="text" id="model" name="model" required placeholder="Enter car model">
</div>
<div>
<label for="location">Location:</label>
<input type="text" id="location" name="location" required placeholder="Enter location">
</div>
<button type="submit">Search</button>
</form>
</div>
<div class="car_container">
<h2 class="heading">Car for sell</h2>
<div class="cars_wrap">
<?php
$connect = mysqli_connect( 'localhost','root','','carselling' );
if( !$connect ){
echo "no connection betweeen database and website ";
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$model = $_POST["model"];
$location = $_POST["location"];
$sql = "SELECT * FROM newcars WHERE carmodel LIKE '%$model%' AND carlocation LIKE '%$location%'";
$result = $connect->query($sql);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$carmodel = $row["carmodel"];
$carmake = $row["carmake"];
$carprice = $row["carprice"];
$carlocation = $row["carlocation"];
echo ' <div class="single_Car">
<div class="about_Car">
<div class="car_model"><h2>' . $carmake . '</h2></div>
<div class="car_model"><h4>' . $carmodel . '</h4></div>
<div class="car_price">$' . $carprice . '</div>
<div class="car_location">' . $carlocation . '</div>
</div>
</div> ';
}
echo "</table>";
} else {
echo "No matching cars found.";
}
}
$connect->close();
?>
</div>
</div>
<!-- script -->
<script src="./src/app.js"></script>
</body>
</html>