-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
75 lines (58 loc) · 2.62 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
<?php
include_once('resources/init.php');
//search option
if (!isset($_GET['search']) || $_GET['search'] == NULL) {
//header("Location:404.php");
echo 'Not Found';
} else {
$search = $_GET['search'];
}
?>
<!--Header-->
<?php require_once 'header.php'; ?>
<!-- Content
================================================== -->
<div id="content-wrap">
<div class="row">
<div id="main" class="eight columns">
<article class="entry">
<?php
$query = "SELECT * FROM posts WHERE title LIKE '%$search%' || contents LIKE '%$search%'";
$post = mysqli_query($conn, $query);
if ($post) {
while ($result = mysqli_fetch_assoc($post)) {?>
<header class="entry-header">
<h2 class="entry-title">
<h2><a href='index.php?id=<?= $result['post_id']; ?>'><?= $result['title']; ?></a></h2>
</h2>
<div class="entry-meta">
<ul>
<li> <?= date('d-m-y h:i:s:a', strtotime($result['date_posted'])); ?></li>
<span class="meta-sep">•</span>
<?php //foreach($postss as $poost){?>
<li>
<a href="#" title="" rel="category tag">In
<a href='category.php?id=<?php //echo $poost['category_id']; ?>' ><?php //echo "<font color='green'>".$poost['name']."</font>"; ?></a>
</li>
<?php //} ?>
<span class="meta-sep">•</span>
<li><!-- Blogger user--></li>
</ul>
</div>
</header>
<div class="entry-content">
<p><?= nl2br($result['contents']); ?></p>
</div>
<?php }}else{?>
<h3 style="color: red; text-align: center">Your Search Query Not Found !!</h3>;
<?php } ?><!-- End if loop -->
</article> <!-- end entry -->
</div> <!-- end main -->
<!-- start sidebar -->
<?php require_once 'sidebar.php'; ?>
<!-- end sidebar -->
</div> <!-- end row -->
</div> <!-- end content-wrap -->
<!-- Footer
================================================== -->
<?php require_once 'footer.php'; ?>