-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchives.php
51 lines (47 loc) · 1.73 KB
/
archives.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
<?php include './inc/conn.php'; ?>
<?php require_once './inc/utils.php'; ?>
<!DOCTYPE html>
<html lang="zh-Hant-TW">
<?php
$web_title = 'Archive « enter3017sky Blog';
include_once './inc/head.php';
?>
<body>
<?php include './inc/navbar.php' ; ?>
<div class="container">
<header class="jumbotron text-center bg-white">
<h1>Archive</h1>
</header>
<div class="box_shadow col-md-10 col-xl-8 mx-auto p-3">
<ul class="list-group list-group-flush">
<?php
$sql = "SELECT * FROM articles WHERE draft=0 ORDER BY created_at DESC";
$stmt = $pdo->prepare($sql);
$stmt->execute();
if($stmt->rowCount() > 0) {
while($row = $stmt->fetch()) {
// 顯示時間
$created_at = new DateTime($row['created_at']);
$year = $created_at->format('l, M d Y');
$date = $created_at->format('M d');
$title = escape($row['title']);
$id = $row['id'];
print "
<a href='./article.php?id=$id' class='list-group-item list-group-item-action'>
<div class='d-flex flex-row'>
<time class='datetime mr-3'>$date</time>
<h3 class='truncate'>$title</h3>
</div>
</a>";
}
}
?>
</ul>
</div>
<footer class="blog__footer text-center m-3 mt-5">
<p>Copyright © 2019 - enter3017sky</p>
</footer>
</div>
<!-- -->
</body>
</html>