51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
include 'include/db.php';
|
|
|
|
$sql = "SELECT * FROM articles ORDER BY date_creation DESC LIMIT 10";
|
|
$result = $pdo->query($sql);
|
|
$articles = $result->fetchAll();
|
|
?>
|
|
|
|
<!-- Page Principal -->
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Accueil - Un CMS Quoi</title>
|
|
<link rel="stylesheet" href="assets/style.css">
|
|
</head>
|
|
<body>
|
|
|
|
<header>
|
|
<nav>
|
|
<a href="index.php">Un Accueil qui Accueil</a> |
|
|
<a href="admin/connexion.php">Administration</a>
|
|
</nav>
|
|
</header>
|
|
|
|
<main>
|
|
<h1>Articles Publiés</h1>
|
|
|
|
<?php
|
|
if (count($articles) == 0) {
|
|
echo "<p>Aucun article trouvé pour le moment.</p>";
|
|
} else {
|
|
foreach ($articles as $a) {
|
|
echo "<article>";
|
|
echo "<h2><a href='article.php?id=" . $a['id'] . "'>" . htmlspecialchars($a['titre']) . "</a></h2>";
|
|
echo "<small>Publie le " . date("d/m/Y", strtotime($a['date_creation'])) . "</small>";
|
|
echo "<p>" . substr(htmlspecialchars($a['contenu']), 0, 200) . "...</p>";
|
|
echo "<p><a href='article.php?id=" . $a['id'] . "'>Lire la suite</a></p>";
|
|
echo "</article>";
|
|
}
|
|
}
|
|
?>
|
|
</main>
|
|
|
|
<footer>
|
|
<p>© <?php echo date("Y"); ?> - Un CMS qui peut nous mener a la victoire</p>
|
|
</footer>
|
|
|
|
</body>
|
|
</html>
|