42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
global $pdo;
|
|
require 'include/db.php';
|
|
$stmt = $pdo->query('SELECT * FROM articles ORDER BY date_creation DESC LIMIT 10');
|
|
$articles = $stmt->fetchAll();
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Accueil - CMS Simplifié</title>
|
|
<link rel="stylesheet" href="assets/style.css">
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<nav>
|
|
<a href="index.php">Accueil</a> |
|
|
<a href="admin/login.php">Administration</a>
|
|
</nav>
|
|
</header>
|
|
|
|
<main>
|
|
<h1>Articles récents</h1>
|
|
<?php if (empty($articles)): ?>
|
|
<p>Aucun article n'a encore été publié.</p>
|
|
<?php endif; ?>
|
|
|
|
<?php foreach ($articles as $a): ?>
|
|
<article>
|
|
<h2><a href="article.php?id=<?= $a['id'] ?>"><?= htmlspecialchars($a['titre']) ?></a></h2>
|
|
<small>Publié le <?= date('d/m/Y', strtotime($a['date_creation'])) ?></small>
|
|
<p><?= substr(htmlspecialchars($a['contenu']), 0, 200) ?>...</p>
|
|
<p><a href="article.php?id=<?= $a['id'] ?>">Lire la suite...</a></p>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
</main>
|
|
|
|
<footer>
|
|
<p>© <?= date('Y') ?> CMS Simplifié. Tous droits réservés.</p>
|
|
</footer>
|
|
</body>
|
|
</html>
|