-
Notifications
You must be signed in to change notification settings - Fork 2
/
sidebar.php
53 lines (50 loc) · 2.12 KB
/
sidebar.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
<div id="sidebar" class="col-md-4">
<!-- search box -->
<div class="search-box-container">
<h4>Search</h4>
<form class="search-post" action="search.php" method ="GET">
<div class="input-group">
<input type="text" name="search" class="form-control" placeholder="Search .....">
<span class="input-group-btn">
<button type="submit" class="btn btn-danger">Search</button>
</span>
</div>
</form>
</div>
<!-- /search box -->
<!-- recent posts box -->
<div class="recent-post-container">
<h4>Recent Posts</h4>
<?php
include "config.php";
$limit=3;
$sql="SELECT post.post_id,post.title,category.category_name,post.post_date,post.description,post.post_img,post.author,post.category
FROM post
LEFT JOIN category ON post.category=category.category_id ORDER BY post_id DESC LIMIT {$limit}"; //view latest post information
$result=mysqli_query($conn,$sql) or die("Query failed ");
if(mysqli_num_rows($result) > 0 ){
while($row = mysqli_fetch_assoc($result)) {
?>
<div class="recent-post">
<a class="post-img" href="single.php?id=<?php echo $row['post_id'];?>">
<img src="admin/upload/<?php echo $row['post_img'];?>" alt=""/>
</a>
<div class="post-content">
<h5><a href="single.php?id=<?php echo $row['post_id'];?>"><?php echo $row["title"];?></a></h5>
<span>
<i class="fa fa-tags" aria-hidden="true"></i>
<a href='category.php?cid=<?php echo $row["category"];?>'> <?php echo $row["category_name"];?></a>
</span>
<span>
<i class="fa fa-calendar" aria-hidden="true"></i>
<?php echo $row["post_date"];?>
</span>
<a class="read-more" href="single.php?id=<?php echo $row['post_id'];?>">read more</a>
</div>
</div>
<?php }
}
?>
</div>
<!-- /recent posts box -->
</div>