display name of the user instead of id
parent
d72da5ffef
commit
c7408301a1
|
@ -3,15 +3,25 @@ $pdo = new PDO('mysql:host=localhost;dbname=web', 'webstuff', 'Schei// auf Pa$$w
|
||||||
$error = false;
|
$error = false;
|
||||||
$error_message = "";
|
$error_message = "";
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$statement = $pdo->prepare("SELECT * FROM posts WHERE board_id=:id ORDER BY post_time asc");
|
$statement = $pdo->prepare("SELECT * FROM posts WHERE board_id=:bid ORDER BY post_time asc");
|
||||||
$statement->execute(array("id"=>$id));
|
$statement->execute(array("bid"=>$id));
|
||||||
foreach($statement->fetchAll() as $ROW) {
|
foreach($statement->fetchAll() as $ROW) {
|
||||||
|
$error = false;
|
||||||
|
$error_message = "";
|
||||||
|
if (!$error) {
|
||||||
|
$statement = $pdo->prepare("SELECT * FROM users WHERE id=:uid");
|
||||||
|
$statement->execute(array("uid"=>$ROW[user_id]));
|
||||||
|
$user = $statement->fetch();
|
||||||
|
}
|
||||||
|
if (!$result) {
|
||||||
|
$error_message = "Error: SQL error.\n" . $statement->queryString . "\n" . $statement->errorInfo()[2];
|
||||||
|
}
|
||||||
echo "<section>";
|
echo "<section>";
|
||||||
echo "<h1>$ROW[id]</h1>";
|
echo "<h1>$ROW[id]</h1>";
|
||||||
echo "<article>";
|
echo "<article>";
|
||||||
echo "<header>";
|
echo "<header>";
|
||||||
echo "<div>";
|
echo "<div>";
|
||||||
echo "<p class='beige'>$ROW[user_id] <time datetime='$ROW[post_time]'>$ROW[post_time]</time></p>";
|
echo "<p class='beige'>$user['name'] <time datetime='$ROW[post_time]'>$ROW[post_time]</time></p>";
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
echo "</header>";
|
echo "</header>";
|
||||||
echo "<div class='postcontent'>";
|
echo "<div class='postcontent'>";
|
||||||
|
|
Loading…
Reference in New Issue