-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
76 lines (74 loc) Β· 2.43 KB
/
search.php
File metadata and controls
76 lines (74 loc) Β· 2.43 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
<!-- start header -->
<?php
$pageTitle = "Search";
include "./components/header.php";
?>
<!-- end header -->
<!-- main-section start -->
<div class="container">
<div class="heading_container mb-3 mt-3">
<h2>
<?php
if (isset($_GET['search'])) {
$search = $_GET['search'];
echo "SEARCH FOR '$search' IS";
}
?>
</h2>
</div>
<?php
if (isset($_GET['search'])) {
$search = $_GET['search'];
require "./database/database.php";
$searchList = "SELECT * FROM `thread` JOIN registration ON thread.register_id = registration.id where thread.thread_name LIKE '%$search%';";
$searchItems = $conn->query($searchList);
if ($searchItems->num_rows > 0) {
foreach ($searchItems as $item) {
echo '<div class="container mb-3 pt-2 pb-2" style="background-color: #1cbbb4;border-radius:5px;">
<div class="row no-gutters align-items-center">
<div class="col-auto">
<img src="./static/images/user.png" alt="" height="50" width="50">
</div>
<div class="col ml-2">
<div>
' . $item['username'] . '
</div>
<div class="d-flex justify-content-between align-items-center">
<div>
' . $item['email'] . '
</div>
<div>
' . substr($item['created_at'], 0, 10) . '
</div>
</div>
</div>
</div>
<div class="container mt-2">
<a style="color:black;font-size:1.5rem;" href="comments.php?id=' . $item['thread_id'] . '" >
' . $item['thread_name'] . '
</a>
<div>';
if (strlen($item['thread_description']) <= 20) {
echo $item['thread_description'];
} else {
echo substr($item['thread_description'], 0, 20) . '...';
}
echo '</div></div>
</div>';
}
} else {
echo '
<div class="alert alert-dark" role="alert">
There is No Items similare to ' . $_GET['search'] . ' !!!
</div>
';
}
}
?>
</div>
<!-- end main-session -->
<!-- start Footer -->
<?php
include "./components/footer.php";
?>
<!-- end footer -->