-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearch.php
More file actions
34 lines (26 loc) · 781 Bytes
/
Copy pathsearch.php
File metadata and controls
34 lines (26 loc) · 781 Bytes
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
<?php
include("header.php");
include("connect.php");
if(isset($_GET['q'])) {
$q = mysqli_real_escape_string($dbcon, $_GET['q']);
$sql = "SELECT * FROM posts WHERE title LIKE '%{$q}%' OR description LIKE '%{$q}%'";
$result = mysqli_query($dbcon, $sql);
if(mysqli_num_rows($result) < 1) {
echo "Nothing found.";
}
while ($row = mysqli_fetch_assoc($result)) {
$id = $row['id'];
$title = $row['title'];
$des = $row['description'];
echo '<div class="w3-panel w3-sand w3-card-4">';
echo "<h3><a href='view.php?id=$id'>$title</a></h3><p>";
echo substr($des, 0,100);
echo '</p><div class="w3-text-light-green">';
echo "<a href='view.php?id=$id'>Read more...</a>";
echo '</div> <div class="w3-text-grey">';
echo "$time</div>";
echo '</div>';
}
}
include("footer.php");
?>