Likes:
Erstellt am:
prepare("SELECT username, email, created_at FROM users WHERE id = :id"); $stmt1->execute([':id' => $userId]); $user = $stmt1->fetch(PDO::FETCH_ASSOC); //Profilbild wird vom angemeldeten benutzer ausgelesen $stmt2 = $pdo->prepare("SELECT file_path FROM profile_pictures WHERE user_id = :user_id"); $stmt2->execute([':user_id' => $userId]); $profile_pic = $stmt2->fetch(PDO::FETCH_ASSOC); //Benutzername und Profilbild werden von allen benutzer ausgelesen $stmt3 = $pdo->prepare(" SELECT users.username, profile_pictures.file_path FROM users LEFT JOIN profile_pictures ON users.id = profile_pictures.user_id ORDER BY profile_pictures.uploaded_at DESC "); $stmt3->execute(); $users = $stmt3->fetchAll(PDO::FETCH_ASSOC); //Alle beiträge von allen benutzer werden ausgelesen $stmt4 = $pdo->prepare(" SELECT posts.*, profile_pictures.file_path AS profile_picture, users.username FROM posts LEFT JOIN profile_pictures ON posts.user_id = profile_pictures.user_id LEFT JOIN users ON posts.user_id = users.id ORDER BY posts.created_at DESC "); $stmt4->execute(); $posts = $stmt4->fetchAll(PDO::FETCH_ASSOC); if ($profile_pic) { $profile_image = $profile_pic['file_path']; } else { $profile_image = 'profile-pics/default.jpeg'; } if(!$user){ die("Benutzer nicht gefunden!"); } }catch (PDOException $e){ die("Fehler: " . $e->getMessage()); } ?>
'; ?>Email: !
Regestriert seit:, !
Erstellt am: