-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsearch.php
73 lines (66 loc) · 2.55 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
<?php
include("includes/header.php");
include("includes/navbar.php");
if(isset($_GET["submit"]))
{
$q=$_GET["search"];
$q=mysqli_real_escape_string($con,$q);
$q=htmlentities($q);
$sql="SELECT title,content,p.id as p_id,feature_image FROM posts p ,users u WHERE p.author=u.id AND (p.title like '$q' OR p.content like '$q' OR p.title like '%$q%' OR p.content like '%$q%')" ;
//echo $sql;
$res=mysqli_query($con,$sql);
if(mysqli_num_rows($res)>0)
{
?>
<div class="row">
<!-- start of main content area-->
<div class="col l9 m9 s12" >
<?php
while($row=mysqli_fetch_assoc($res))
{
?>
<!-- Card Start from here -->
<div class="col l3 m4 s6">
<div class="card small">
<div class="card-image">
<img src="img/<?php echo $row["feature_image"]?>" alt="" style="height:150px" class="img-responsive">
<span class="card-title"><?php echo $row["title"]?></span>
</div>
<div class="card-content">
<?php echo $row["content"];?>
</div>
<div class="card-action teal center">
<a href="post.php?id=<?php echo $row['p_id'];?>" class="white-text">Read more...</a>
</div>
</div>
</div>
<!-- Card End from here -->
<?php
}
?>
</div>
<!-- start of main content area-->
<!-- start of sidebar content area-->
<div class="col l3 m3 s12" >
<?php
include("includes/sidebar.php");
?>
</div>
<!-- end of sidebar content area-->
<?php
}
else
{
?>
<h5>NO data found with the given search keywords, try searching with other keywords!</h5>
<?php
}
}
else
{
header("location:index.php");
}
?>
<?php
include("includes/header.php");
?>