added php to display all posts from our database
parent
7a9a5bcbe7
commit
a2efbb6d41
|
@ -1,13 +1,29 @@
|
||||||
<section>
|
<?php
|
||||||
<h1>Lorem ipsum</h1>
|
$pdo = new PDO('mysql:host=localhost;dbname=web', 'webstuff', 'Schei// auf Pa$$w0rter!');
|
||||||
<article>
|
$error = false;
|
||||||
<header>
|
$error_message = "";
|
||||||
<div>
|
if (!$error) {
|
||||||
<p class="beige">Lorem ipsum blabblabludbjfdla <time datetime="2020-03-08 02:25">Frauentag</time></p>
|
echo '<center><h2 class="beige">Public Boards</h2></center>';
|
||||||
</div>
|
$statement = $pdo->prepare("SELECT * FROM posts WHERE board_id=$id ORDER BY post_time asc");
|
||||||
</header>
|
$statement->execute();
|
||||||
<div class="postcontent">
|
foreach($statement->fetchAll() as $ROW) {
|
||||||
<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>
|
echo "<section>"
|
||||||
</div>
|
echo " <h1>$ROW[id]</h1>"
|
||||||
</article>
|
echo " <article>"
|
||||||
</section>
|
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];
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue