表白墙

登录后发表内容。

表白内容

prepare("SELECT love_wall.id, love_wall.content, users.username FROM love_wall JOIN users ON love_wall.user_id = users.id ORDER BY love_wall.created_at DESC"); $stmt->execute(); while ($row = $stmt->fetch()) { echo "
" . htmlspecialchars($row['username']) . ": " . htmlspecialchars($row['content']) . "
"; echo "
"; // 加载评论 $commentStmt = $pdo->prepare("SELECT comments.content, users.username FROM comments JOIN users ON comments.user_id = users.id WHERE love_wall_id = ? ORDER BY comments.created_at DESC"); $commentStmt->execute([$row['id']]); while ($comment = $commentStmt->fetch()) { echo "
" . htmlspecialchars($comment['username']) . ": " . htmlspecialchars($comment['content']) . "
"; } echo "
"; if (isset($_SESSION['user_id'])) { echo "
"; echo ""; echo ""; echo "
"; } echo "
"; } ?>