query(' SELECT posts.id, posts.content, posts.created_at, users.display_name, users.id as user_id, (SELECT COUNT(*) FROM post_votes WHERE post_id = posts.id AND vote = 1) as likes, (SELECT COUNT(*) FROM post_votes WHERE post_id = posts.id AND vote = -1) as dislikes FROM posts JOIN users ON posts.user_id = users.id ORDER BY posts.created_at DESC '); $posts = $stmt->fetchAll(PDO::FETCH_ASSOC); } catch (PDOException $e) { // Handle database errors gracefully error_log("DB Error: " . $e->getMessage()); } ?> Welcome to Our Social Platform
Create a Post

Feed

No posts yet. Be the first to share!
Posted on

Connect and Share

Join our community to connect with friends, share your thoughts, and discover new things.

Get Started Have an account? Login