-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
264 lines (230 loc) · 10.9 KB
/
search.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
<!-- //session_start(); -->
<?php
// i0f(!isset($_SESSION['UserName'])){
// die(header("location: index.php"));
// }
// else{
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Welcome to iCoder. A blog for coding enthusiasts">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>Searhed</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="index.php">ePaintings</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="index.php">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.php">About</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Browse
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="artist.php">Artist</a>
<a class="dropdown-item" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
Paintings
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="genre.php">Genre</a>
</div>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.php">Contact Us</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0" action="search.php" method="post">
<input class="form-control mr-sm-2" name="search" type="text" placeholder="Search" aria-label="Search">
<button name="submit" class="btn btn-outline-light my-2 my-sm-0" type="submit">Search</button>
</form>
<div class="mx-2">
<button class="btn btn-danger" data-toggle="modal" data-target="#loginModal">Login</button>
<button class="btn btn-danger" data-toggle="modal" data-target="#signupModal">SignUp</button>
</div>
</div>
</nav>
<!-- Login Modal -->
<div class="modal fade" id="loginModal" tabindex="-1" role="dialog" aria-labelledby="loginModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Login to Epaintings</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="login.php" method="POST">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" name="exampleInputEmail1" id="exampleInputEmail1"
aria-describedby="emailHelp">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone
else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" name="exampleInputPassword1"
id="exampleInputPassword1">
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Check me out</label>
</div>
<button name="submit" type="submit" class="btn btn-primary">Login</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- Sign Up Modal -->
<div class="modal fade" id="signupModal" tabindex="-1" role="dialog" aria-labelledby="signupModalLabel"
aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Create Account</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form action="signup.php" method="POST">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" name="exampleInputEmail1" id="exampleInputEmail1"
aria-describedby="emailHelp">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone
else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" name="exampleInputPassword1"
id="exampleInputPassword1">
</div>
<div class="form-group">
<label for="cexampleInputPassword1">Confirm Password</label>
<input type="password" class="form-control" name="cexampleInputPassword1"
id="cexampleInputPassword1">
</div>
<button name="submit" type="submit" class="btn btn-primary">Creat Account</button>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "art";
// create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// check connection
if (!$conn) {
die("connection failed" . mysqli_connect_error());
}
if (isset($_POST['submit'])) {
$searchValue = $_POST["search"];
// $query = mysqli_query($conn,"SELECT * FROM artists where Firstname = '$searchValue'
// or LastName = '$searchValue'
// or Nationality = '$searchValue'");
$query = mysqli_query($conn, "SELECT * From artists
inner JOIN paintings
ON artists.ArtistID = paintings.ArtistID
where artists.Firstname = '$searchValue'
or artists.LastName = '$searchValue'
or artists.Nationality = '$searchValue'
or paintings.Title = '$searchValue'");
// $query = mysqli_query($conn, "SELECT * FROM artists");
// $result = $mysqli->query($query);
// while($row = $result->fetch_array())
// echo $query;
// $row = mysqli_fetch_array($query);
while ($row = mysqli_fetch_array($query)) {
$firstName = $row['FirstName'];
$lastName = $row['LastName'];
$title = $row['Title'];
$gender = $row['Gender'];
$nationaltiy = $row['Nationality'];
$birthYear = $row['YearOfBirth'];
$deathYear = $row['YearOfDeath'];
$details = $row['Details'];
?>
<div class="container my-4">
<table class="table table-striped">
<thead>
<tr>
<th>First Name</th>
<th>Last Name</th>
<th>Title</th>
<th>Gender</th>
<th>Nationality</th>
<th>Birth Year</th>
<th>Death Year</th>
<th>Details</th>
</tr>
</thead>
<tbody>
<tr>
<th><?php echo $firstName; ?></th>
<th><?php echo $lastName; ?></th>
<th><?php echo $title; ?></th>
<th><?php echo $gender; ?></th>
<th><?php echo $nationaltiy; ?></th>
<th><?php echo $birthYear; ?></th>
<th><?php echo $deathYear; ?></th>
<th><?php echo $details; ?></th>
</tr>
</tbody>
</table>
</div>
<?php }}
mysqli_free_result($query);
?>
<footer class="container">
<p class="float-right"><a href="#">Back to top</a></p>
<p>© 2020-2021 Epaintings, Inc. · <a href="#">Privacy</a> · <a href="#">Terms</a></p>
</footer>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous">
</script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous">
</script>
</body>
</html>
<?php
// }
?>