Files
CMS-Simplifie/index.php
2025-11-02 18:08:53 +01:00

43 lines
1.1 KiB
PHP

<?php
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</title>
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<header>
<nav>
<a href="index.php">Accueil</a> |
<a href="admin/login.php">Administratreur</a>
</nav>
</header>
<main>
<h1>Articles</h1>
<?php if (empty($articles)): ?>
<p>Aucun Article pour le moment</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>&copy; <?= date('Y') ?> CMS. Tous droits réservés par Abd'R.</p>
</footer>
</body>
</html>