-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharticle.php
More file actions
48 lines (34 loc) · 1.26 KB
/
article.php
File metadata and controls
48 lines (34 loc) · 1.26 KB
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
<?php
require "includes/init.php";
if (isset($_GET["id"])) {
$link = require "includes/db.php";
$article = Article::getWithCategories($link, $_GET["id"], true);
} else {
echo "This is bullshit, try again...";
$article = null;
}
?>
<?php include "includes/header.php"; ?>
<?php if ($article): ?>
<!-- doing var_dump($article); will show that internal array is at index 0 -->
<h2><?= htmlspecialchars($article[0]["title"]); ?></h2>
<!-- machine readable datetime is in attribute -->
<time datetime="<?php echo $article[0]["published_at"]; ?>"><?php
$datetime = new DateTime($article[0]["published_at"]);
echo $datetime->format("F j, Y");
?></time>
<?php if ($article[0]["category_name"]): ?>
<p>Categories:
<?php foreach ($article as $internal_arr) : ?>
<strong><?= $internal_arr["category_name"] ?></strong>
<?php endforeach; ?>
</p>
<?php endif; ?>
<?php if ($article[0]["image_file"]): ?>
<img src="/uploads/<?= $article[0]["image_file"] ?>">
<?php endif; ?>
<p><?= htmlspecialchars($article[0]["content"]); ?></p><br>
<?php else: ?>
<p>There's nothing new here.</p>
<?php endif; ?>
<?php include "includes/footer.php"; ?>