-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
78 lines (74 loc) · 2.83 KB
/
Copy pathsearch.php
File metadata and controls
78 lines (74 loc) · 2.83 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
<?php include 'includes/config.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hostel Tracker</title>
<meta charset="utf-8">
<?php include 'includes/links.php'; ?>
</head>
<body>
<?php include 'includes/header.php'; ?>
<div class="admin-form">
<?php
if (isset($_GET['keyword'])) {
$query = "";
if($_GET['type']=='city')
{
$query = "SELECT * FROM hostels where hostel_city like '%".$_GET['keyword']."%'";
}
else if($_GET['type']=='name')
{
$query = "SELECT * FROM hostels where hostel_name like '%".$_GET['keyword']."%'";
}
?>
<h1>Search Results!</h1>
<div>
<?php
$result = $db->query($query);
if (!empty($result)) {
?>
<table>
<thead>
<tr>
<th>Hostel Name</th>
<th>Hostel Type</th>
<th>Hostel City</th>
<th>Hostel Sector</th>
<th>Hostel Address</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
while ($item = mysqli_fetch_assoc($result)) {
?>
<tr>
<td><?php echo $item['hostel_name'] ?></td>
<td><?php echo $item['hostel_type'] ?></td>
<td><?php echo $item['hostel_city'] ?></td>
<td><?php echo $item['hostel_sector'] ?></td>
<td><?php echo $item['hostel_address'] ?></td>
<td>
<a href="hostel.php?id=<?php echo $item['id'] ?>">View Details</a>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
?>
</div>
<?php
}
else
{
?><p>Not Logged In!</p><?php
}
?>
</div>
<?php include 'includes/footer.php'; ?>
</body>
</html>