-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
31 lines (26 loc) · 993 Bytes
/
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
<?php include "includes/header.php";?>
<?php
//Create database object
$db = new Database();
//create query
$query = "SELECT * FROM `posts` ORDER BY id DESC";
//run query
$posts = $db->select($query);
//create query
$query = "SELECT * FROM `categories`";
//run query
$categories = $db->select($query);
?>
<?php if($posts):?>
<?php while($row = $posts->fetch_assoc()) :?>
<div class="blog-post">
<h2 class="blog-post-title"><?php echo $row['title'];?></h2>
<p class="blog-post-meta"><?php echo formatDate($row['date']);?> by <a href="#"><?php echo $row['author'];?></a></p>
<?php echo shortenText($row['body']);?>
<a class ="readmore" href="post.php?id=<?php echo urlencode($row['id']);?>">Read More</a>
</div><!-- /.blog-post -->
<?php endwhile;?>
<?php else:?>
<p>There are no posts yet</p>
<?php endif;?>
<?php include "includes/footer.php";?>