first commit
This commit is contained in:
32
public/index.php
Normal file
32
public/index.php
Normal 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';
|
||||
?>
|
||||
Reference in New Issue
Block a user