-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
49 lines (45 loc) · 1.06 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
<?php
require_once './lib/database.php';
if (isset($_GET['category'])) {
$posts = post_find_by_category_id($_GET['category']);
} else {
$posts = post_all();
}
$categories = category_all();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Blog</title>
<link rel="stylesheet" href="./css/index.css">
</head>
<body>
<header>Simple Responsive blog</header>
<div class="content">
<aside>
<?php
$html = '';
foreach ($categories as $category) {
$html .= "<a href='index.php?category={$category['id']}'>{$category['name']}</a>";
}
echo $html;
?>
</aside>
<section class="articles">
<?php
$html = '';
foreach ($posts as $post) {
$article = '<article>';
$article .= "<h4>{$post['title']}</h4><hr/>";
$article .= $post['body'];
$article .= '</article>';
$html .= $article;
}
echo $html;
?>
</section>
</div>
<footer>All rights reserved!</footer>
</body>
</html>