-
Notifications
You must be signed in to change notification settings - Fork 0
/
blog.php
57 lines (48 loc) · 1.57 KB
/
blog.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
54
55
56
57
<?php
include('includes/config.php');
include('includes/database.php');
include('includes/functions.php');
if ($stm = $connect->prepare('SELECT * from posts')) {
$stm->execute();
$result = $stm->get_result();
$posts = $result->fetch_all(MYSQLI_ASSOC);
if ($posts) {
$title = "My Blogs";
} else {
echo "No blogs found";
die();
}
$stm->close();
} else {
echo 'Could not prepare statement!';
die();
}
include('includes/header.php');
?>
<div class="container mt-5">
<div class="row justify-content-center">
<div class="col-md-10">
<h4 class="display-6"><?php echo $title ?></h4>
<hr>
<?php foreach ($posts as $post) { ?>
<div class="card mb-3">
<div class="card-body">
<h5 class="card-title"><?php echo $post['title'] ?></h5>
<div class="row">
<div class="col-6">
<p class="card-text">ID: <?php echo $post['id'] ?></p>
</div>
<div class="col-6">
<p class="card-text text-end">Date: <?php echo $post['date'] ?></p>
</div>
</div>
<p class="card-text"><?php echo $post['content'] ?></p>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
<?php
include('includes/footer.php');
?>