prepare('SELECT display_name, description, occupation FROM users WHERE id = ?'); $stmt->execute([$user_id]); $user = $stmt->fetch(); if (!$user) { header('Location: index.php'); exit(); } $stmt = $p->prepare('SELECT p.id, p.content, p.created_at, u.display_name, (SELECT COUNT(*) FROM post_votes WHERE post_id = p.id AND vote = 1) as likes, (SELECT COUNT(*) FROM post_votes WHERE post_id = p.id AND vote = -1) as dislikes FROM posts p JOIN users u ON p.user_id = u.id WHERE p.user_id = ? ORDER BY p.created_at DESC'); $stmt->execute([$user_id]); $posts = $stmt->fetchAll(); ?>
= htmlspecialchars($user['description']) ?>
= htmlspecialchars($user['occupation']) ?>
This user has no posts yet.
= htmlspecialchars($post['content']) ?>
Posted on = date('F j, Y, g:i a', strtotime($post['created_at'])) ?>