23 lines
640 B
PHP
23 lines
640 B
PHP
<?php
|
|
require 'includes/db.php';
|
|
include 'includes/header.php';
|
|
|
|
$sql = "SELECT * FROM articles ORDER BY date_creation DESC LIMIT 10";
|
|
$stmt = $pdo->query($sql);
|
|
$articles = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
?>
|
|
|
|
<h2>Derniers articles</h2>
|
|
|
|
<?php if (empty($articles)): ?>
|
|
<p>Aucun article pour le moment.</p>
|
|
<?php else: ?>
|
|
<?php foreach ($articles as $a): ?>
|
|
<h3><a href="article.php?id=<?= $a['id'] ?>"><?= htmlspecialchars($a['titre']) ?></a></h3>
|
|
<p><?= substr(htmlspecialchars($a['contenu']), 0, 150) ?>...</p>
|
|
<hr>
|
|
<?php endforeach; ?>
|
|
<?php endif; ?>
|
|
|
|
<?php include 'includes/footer.php'; ?>
|