first commit

This commit is contained in:
2025-11-02 19:42:11 +01:00
commit a6995fbab5
15 changed files with 471 additions and 0 deletions

32
public/index.php Normal file
View File

@@ -0,0 +1,32 @@
<?php
include 'includes/header.php';
include 'includes/db.php';
?>
<main>
<h2>Derniers articles</h2>
<?php
$sql = "SELECT * FROM articles ORDER BY date_creation DESC LIMIT 10";
$stmt = $pdo->prepare($sql);
$stmt->execute();
$articles = $stmt->fetchAll(PDO::FETCH_ASSOC);
if ($articles) {
foreach ($articles as $article) {
echo '<article>';
echo '<h3>' . htmlspecialchars($article['titre']) . '</h3>';
echo '<p>' . substr(htmlspecialchars($article['contenu']), 0, 100) . '...</p>';
echo '<a href="article.php?id=' . $article['id'] . '">Lire la suite</a>';
echo '</article><hr>';
}
} else {
echo "<p>Aucun article publié pour le moment.</p>";
}
?>
</main>
<?php
include 'includes/footer.php';
?>