-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthor.php
More file actions
82 lines (70 loc) · 3.56 KB
/
author.php
File metadata and controls
82 lines (70 loc) · 3.56 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
75
76
77
78
79
80
81
<!-- Connection -->
<?php session_start(); ?>
<?php
include "./includes/db.php";
?>
<!-- Header -->
<?php
include "./includes/header.php";
?>
<!-- Navigation -->
<?php
include "./includes/navigation.php";
?>
<?php
if(isset($_GET['author'])){
$query_posts = "SELECT * FROM `posts` WHERE post_author='{$_GET['author']}' ORDER BY post_id DESC";
$res_posts = mysqli_query($connection,$query_posts);
if(!$row = mysqli_fetch_assoc($res_posts)){
echo "<h1 class='text-center'>No Post Published Yet by '{$_GET['author']}'</h1>";
}
else{
$query_posts = "SELECT * FROM `posts` WHERE post_status='published' ORDER BY post_id DESC";
$res_posts = mysqli_query($connection,$query_posts);
while ($row = mysqli_fetch_assoc($res_posts)){
$post_id = $row["post_id"];
$post_category_id = $row["post_category_id"];
$post_title = $row["post_title"];
$post_author = $row["post_author"];
$post_date = $row["post_date"];
$post_content = $row["post_content"];
$post_image = $row["post_image"];
$post_tags = $row["post_tags"];
$post_status = $row["post_status"];
?>
<main>
<div class="container">
<div class="row">
<article class="blog-item">
<div class="row">
<div class="col-md-3">
<a href="singlePost.php?p_id=<?php echo $post_id; ?>">
<img src="image/<?php echo $post_image; ?>" class="img-thumbnail center-block" alt="Blog Post Thumbnail">
</a>
</div>
<div class="col-md-9">
<p>
Posted By
<a href="author.php?author=<?php echo $post_author; ?>"><?php echo $post_author; ?></a>
,
<?php
$categoryQuery = "SELECT cat_title FROM `categories` WHERE cat_id={$post_category_id}";
$categoryQueryResult = mysqli_query($connection,$categoryQuery);
while ($row = mysqli_fetch_assoc($categoryQueryResult)){
$get_Category = $row["cat_title"];
echo "<a href='category.php?category_id={$post_category_id}'>{$get_Category}</a>,";
}
?>
<time><?php echo $post_date; ?><time>
</p>
<h1>
<a href="singlePost.php?p_id=<?php echo $post_id; ?>"><?php echo $post_title; ?></a>
</h1>
<p><?php echo substr($post_content,0,100)."..."; ?></p>
<p><strong>Tags</strong> : <?php echo $post_tags ?></p>
</div>
</div>
</article>
</div>
</div>
<?php }}} ?>