19 lines
615 B
PHP
19 lines
615 B
PHP
#<?php
|
|
require_once __DIR__ . '/includes/db.php';
|
|
require_once __DIR__ . '/includes/header.php';
|
|
|
|
$stmt = $pdo->query("SELECT id, titre, SUBSTRING(contenu, 1, 150) AS extrait, date_creation
|
|
FROM articles ORDER BY date_creation DESC LIMIT 10");
|
|
|
|
echo "<h2>Derniers articles</h2>";
|
|
|
|
while ($row = $stmt->fetch()) {
|
|
echo "<article>";
|
|
echo "<h3><a href='article.php?id={$row['id']}'>{$row['titre']}</a></h3>";
|
|
echo "<p>{$row['extrait']}...</p>";
|
|
echo "<small>Publié le {$row['date_creation']}</small>";
|
|
echo "</article><hr>";
|
|
}
|
|
|
|
require_once __DIR__ . '/includes/footer.php';
|