-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSearch.php
51 lines (31 loc) · 1.31 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
<?php
require_once("action/SignInAction.php");
$action = new SignInAction();
$action->execute();
require_once("partial/Header.php");
$connection = Connection::getConnection();
if (isset($_REQUEST['query'])) {
$query = $_REQUEST['query'];
$check = $connection->prepare("SELECT * FROM post WHERE (`post_title` LIKE '%" . $query . "%') OR (`post_content` LIKE '%" . $query . "%')");
$check->bindParam(1, $query);
$check->execute();
if ($check->rowCount() > 0) {
echo "<h2>Search Result</h2>";
while ($results = $check->fetch(PDO::FETCH_ASSOC)) {
echo "<form name=\"title\" action=\"index.php\" method=\"post\">";
echo "<input type=\"hidden\" name=\"post_id\" value=\"" . $results['post_id'] . "\"></input>";
echo "<button type=\"submit\" class=\"notButton\">" . $results['post_title'] . "</button></form>";
echo "<p>   <strong> Posted:</strong>" . $results['post_creation_time'] . "</p>";
echo "<p>   " . $results['post_content'] . "</p>";
}
} else {
echo "No results found.";
}
}
else {
echo "No results found ";
}
?>
<?php
require_once("partial/Footer.php");
?>