<?php
require_once 'lib/common.php';
session_start();

$db = initDatabase();
$req = mysqli_query($db,"SELECT * FROM article");

$articles=mysqli_fetch_all($req);

?>

<?php
include './templates/header.php';
?>

<body container>

<h1>Liste des articles</h1>

<?php
if (!empty($_SESSION['user'])) {
	echo "<p>Bonjour, " . $_SESSION['user']['name']. ".</p>";
}
?>

<ul>
<?php
foreach ($articles as $article) {
	echo '<li><a href="article_view.php?id=' . $article[0].'">'
		. $article[1] . "</a></li>\n";
}
?>
</ul>

<?php
include './templates/footer.php';
?>

</body>
</html>
