-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthor_posts.php
More file actions
69 lines (65 loc) · 2.81 KB
/
Copy pathauthor_posts.php
File metadata and controls
69 lines (65 loc) · 2.81 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
<!DOCTYPE html>
<html lang="en">
<?php include "includes/db.php";
include "includes/head.php"; ?>
<body>
<!-- Responsive navbar-->
<?php include "includes/navbar.php" ?>
<!-- Page content-->
<div class="container mt-5">
<div class="row">
<div class="col-lg-8">
<?php
if (isset($_GET['p_id'])) {
$post_id = $_GET['p_id'];
$post_author = $_GET['author'];
} ?>
<h2>All posts by
<?php echo $post_author ?>
</h2>
<?php
$query = "SELECT * FROM posts WHERE author = '{$post_author}'";
$select_post = mysqli_query($connection, $query);
while ($row = mysqli_fetch_assoc($select_post)) {
$post_id = $row['id'];
$post_title = $row['title'];
$post_date = $row['date'];
$post_content = substr($row['content'], 0, 200);
$post_content .= "... Czytaj dalej!";
$post_author = $row['author'];
$post_image = $row['image']; ?>
<div class='card mb-4'>
<a href='post.php?p_id=<?php echo $post_id ?>'><img class='card-img-top post-image'
src='images/<?php echo $post_image ?>' alt='...' /></a>
<div class='card-body'>
<div class='small text-muted'>
<?php echo $post_date ?>
</div>
<h2 class='card-title h4'>
<?php echo $post_title ?>
</h2>
<p class='card-text'>
<?php echo $post_content ?>
</p>
<a class='btn btn-primary' href='post.php?p_id=<?php echo $post_id ?>'>Read more →</a>
<p class='lead'><a
href='author_posts.php?author=<?php echo $post_author ?>&p_id=<?php echo $post_id ?>'
style='text-decoration: none;'>@<?php echo $post_author ?></a></p>
</div>
</div>
<?php } ?>
</div>
<!-- Side widgets-->
<div class="col-lg-4">
<!-- Search widget-->
<?php include "includes/search.php" ?>
<!-- Categories widget-->
<?php include "includes/categories.php" ?>
<!-- Side widget-->
<?php include "includes/side_widget.php" ?>
</div>
</div>
</div>
<?php include "includes/footer.php" ?>
</body>
</html>