-
Notifications
You must be signed in to change notification settings - Fork 0
/
posts.php
64 lines (45 loc) · 1.46 KB
/
posts.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
60
61
62
63
64
<?php
include 'includes/header.php';
//Create Database
$db = new Database();
//Check URL for Category
if(isset($_GET['category'])){
$category = $_GET['category'];
//Create Query
$query= "SELECT * FROM posts WHERE category = ".$category;
//Run Query
$posts= $db-> select ($query);
} else {
//CREATE Query
$query = "SELECT * FROM posts";
//Run Query
$posts = $db->select($query);
}
//Create Featured Post
$query_feat= "SELECT * FROM posts WHERE category=2";
//Run Query
$posts_feat= $db-> select ($query_feat);
//Create Query category
$query2= "SELECT * FROM categories";
//Run Query
$categories= $db-> select ($query2);
//Create Query ID=1
$query_id1= "SELECT * FROM categories WHERE id=1";
//Run Query
$categories_top= $db-> select ($query_id1);
?>
</div>
<main role="main" class="container">
<div class="row">
<div class="col-md-8 blog-main">
<h3 class="pb-3 mb-4 font-italic border-bottom"> </h3>
<?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['timestamp']); ?> by <a href="#"><?php echo $row['author']; ?></a></p>
<?php echo $row['body']; ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif ?>
<?php include 'includes/footer.php'; ?>