-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.php
More file actions
74 lines (61 loc) · 2.87 KB
/
Copy pathuser.php
File metadata and controls
74 lines (61 loc) · 2.87 KB
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
<!-- header -->
<?php
// navbar
include("./include/header.php");
// slider
include("./include/slider.php");
if(isset($_GET['category'])){
$category_id = $_GET['category'];
$query_posts = "SELECT * FROM posts WHERE category_id=$category_id";
$posts = $db->query($query_posts);
}else{
$query_posts = "SELECT * FROM posts";
$posts = $db->query($query_posts);
}
?>
<main style="margin-top:80px;">
<div class="row mt-2">
<!-- Posts container -->
<div class="container-fluid col-sm-7 offset-sm-1 " id="posts">
<div class="row">
<?php
if($posts->rowCount()>0){
foreach($posts as $post){
$post_category_id = $post['category_id'];
$query_category = "SELECT * FROM categories WHERE id=$post_category_id";
$category = $db->query($query_category)->fetch();
$post_user_id = $post['user_id'];
$query_user = "SELECT * FROM users WHERE id=$post_user_id";
$user = $db->query($query_user)->fetch();
echo '<div class="col-md-6" >
<div class="thumbnail">
<img src="./upload/'.$post['media'].'" alt="night sky" style="height:200px">
<div class="row caption position-relative" style="padding-left:20px">
<h3 class="col">'.$post['title'].'</h3>
<a class=" badge badge-secondary" style="background-color:gray;color:lightgray" href="index.php?category='. $category['id'].'" style="text-align:right">'. $category['title'].'</a>
<span class="col position-absolute bottom-50 end-50" style="color:gray; font-size:12px;">'.$post['date'].'</span>
<p>'.substr($post['caption'],0,50).'...</p>
<p class="col">
<a href="single.php?post='.$post['id'].'" class="btn btn-success" role="button">Veiw post</a>
</p>
<p class="col end">Author: '.$user['name'].'</p>
</div>
</div>
</div>';
}
}else{
echo '<div class="alert alert-warning" style="padding-left:25px">No post available!</div>';
}
?>
</div>
</div>
<!-- side bar -->
<?php
include("./include/sidebar.php");
?>
</div>
</main>
<!-- footer -->
<?php
include("./include/footer.php");
?>