47 lines
975 B
PHP
47 lines
975 B
PHP
<?php
|
|
require_once 'php/pdo.php';
|
|
|
|
$sql = "SELECT * FROM articles ORDER BY date_creation DESC";
|
|
$stmt = $pdo->prepare($sql);
|
|
$stmt->execute();
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="fr" dir="ltr">
|
|
<head>
|
|
<meta charset="UTF-8"> <title>Mon Blog</title>
|
|
</head>
|
|
<body>
|
|
|
|
<h1>Mini projet</h1>
|
|
<p>Bienvenue voici les derniers articles :</p>
|
|
|
|
<hr>
|
|
|
|
<?php
|
|
while ($article = $stmt->fetch(PDO::FETCH_ASSOC)) :
|
|
?>
|
|
|
|
<article>
|
|
<h2><?php print htmlspecialchars($article['titre']); ?></h2>
|
|
|
|
<p>
|
|
<em>Publié le : <?php print $article['date_creation']; ?></em>
|
|
</p>
|
|
|
|
<p>
|
|
<?php
|
|
print htmlspecialchars(substr($article['contenu'], 0, 200));
|
|
?>...
|
|
</p>
|
|
|
|
<a href="article.php?id=<?php print $article['id']; ?>">Lire la suite</a>
|
|
</article>
|
|
<hr>
|
|
|
|
<?php
|
|
endwhile;
|
|
?>
|
|
|
|
</body>
|
|
</html>
|