-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.php
51 lines (36 loc) · 1.12 KB
/
post.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
<?php
include 'includes/header.php';
?>
<?php
$post = getPost($_GET['id']);
if(!$post) {
redirect('index.php');
}
?>
<?php
$query = $db->prepare("SELECT * FROM comments WHERE post_id = :post_id");
$query->execute([
'post_id' => $post['id'],
]);
$comments = $query->fetchAll();
// dump($comments);
?>
<h1><?= $post['title'] ?></h1>
<img src="<?= $post['image_path'] ?>" alt="" style="width: 400px">
<p>
<b><?= $post['date'] ?></b>
<a href="index.php?user_id=<?= $post['author']['id'] ?>"><?= $post['author']['name'] ?></a>
</p>
<p><?= $post['description'] ?></p>
<p><?= $post['content'] ?></p>
<h4>Comments</h4>
<?php foreach ($comments as $comment):?>
<p>Имя пользователя: <?= getUser($comment['user_id'])['name']?> | Комментарий: <?= $comment['text'] ?> | Дата добавления комментария: <?= $comment['date'] ?></p>
<?php endforeach; ?>
<?php if(hasAccess($post)): ?>
<a href="edit.php?id=<?= $post['id'] ?>">Edit</a> |
<a href="delete.php?id=<?= $post['id'] ?>">Delete</a>
<?php endif; ?>
<?php
include 'includes/footer.php';
?>