added php to display all posts from our database

master
Jakob 2020-03-08 15:03:30 +01:00
parent 7a9a5bcbe7
commit a2efbb6d41
1 changed files with 29 additions and 13 deletions

View File

@ -1,13 +1,29 @@
<section>
<h1>Lorem ipsum</h1>
<article>
<header>
<div>
<p class="beige">Lorem ipsum blabblabludbjfdla <time datetime="2020-03-08 02:25">Frauentag</time></p>
</div>
</header>
<div class="postcontent">
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
</div>
</article>
</section>
<?php
$pdo = new PDO('mysql:host=localhost;dbname=web', 'webstuff', 'Schei// auf Pa$$w0rter!');
$error = false;
$error_message = "";
if (!$error) {
echo '<center><h2 class="beige">Public Boards</h2></center>';
$statement = $pdo->prepare("SELECT * FROM posts WHERE board_id=$id ORDER BY post_time asc");
$statement->execute();
foreach($statement->fetchAll() as $ROW) {
echo "<section>"
echo " <h1>$ROW[id]</h1>"
echo " <article>"
echo " <header>"
echo " <div>"
echo " <p class="beige">$ROW[user_id] <time datetime="$ROW[post_time]">$ROW[post_time]</time></p>"
echo " </div>"
echo " </header>"
echo " <div class="postcontent">"
echo " <p>$ROW[content]</p>"
echo " </div>"
echo " </article>"
echo "</section>"
}
}
if (!$result) {
$error_message = "Error: SQL error.\n" . $statement->queryString . "\n" . $statement->errorInfo()[2];
}
?>