-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
59 lines (45 loc) · 1.87 KB
/
index.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
58
59
<?php require "includes/header.php"; ?>
<?php require 'config/config.php'; ?>
<?php
$posts = $conn->query("SELECT * FROM posts");
$posts->execute();
$rows = $posts->fetchAll(PDO::FETCH_OBJ);
$categories = $conn->query("SELECT * FROM categories");
$categories->execute();
$categories = $categories->fetchAll(PDO::FETCH_OBJ);
?>
<div class="row gx-4 gx-lg-5 justify-content-center">
<div class="col-md-10 col-lg-8 col-xl-7">
<?php foreach ($rows as $row) : ?>
<!-- Post preview-->
<div class="post-preview">
<a href="http://localhost/clean-blog/posts/post.php?post_id=<?php echo $row->id; ?>">
<h2 class="post-title"><?php echo $row->title; ?></h2>
<h3 class="post-subtitle"><?php echo $row->subtitle; ?></h3>
</a>
<p class="post-meta">
Posted by
<a href="#!"><?php echo $row->user_name; ?></a>
<?php echo date('M', strtotime($row->created_at)) . ',' . date('d', strtotime($row->created_at)) . ',' . date('Y', strtotime($row->created_at)); ?>
</p>
</div>
<!-- Divider-->
<hr class="my-4" />
<?php endforeach; ?>
<!-- Pager-->
</div>
</div>
<div class="row gx-4 gx-lg-5 justify-content-center">
<h3 class="">Categories</h3>
<br><br><br>
<?php foreach ($categories as $cat) : ?>
<div class="col-md-5">
<a href="http://localhost/clean-blog/categories/category.php?cat_id=<?php echo $cat->id; ?>">
<div class="alert alert-dark bg-dark text-center text-white" role="alert">
<?php echo $cat->name; ?>
</div>
</a>
</div>
<?php endforeach; ?>
</div>
<?php require 'includes/footer.php'; ?>