prepare("SELECT v.*, u.username as uploader FROM videos v JOIN users u ON v.uploader_id = u.id WHERE v.id = ?"); $stmt->execute([$video_id]); $video = $stmt->fetch(); if (!$video) { header('Location: index.php'); exit; } // Get Recommendations (videos with same tags) $stmt = $pdo->prepare(" SELECT DISTINCT v.* FROM videos v JOIN video_tags vt ON v.id = vt.video_id WHERE vt.tag_id IN (SELECT tag_id FROM video_tags WHERE video_id = ?) AND v.id != ? LIMIT 4 "); $stmt->execute([$video_id, $video_id]); $recommendations = $stmt->fetchAll(); if (empty($recommendations)) { $stmt = $pdo->prepare("SELECT * FROM videos WHERE id != ? ORDER BY created_at DESC LIMIT 4"); $stmt->execute([$video_id]); $recommendations = $stmt->fetchAll(); } // Fetch comments with reaction counts $stmt = $pdo->prepare(" SELECT c.*, u.username, (SELECT COUNT(*) FROM reactions WHERE comment_id = c.id AND reaction_type = 'thumb') as thumbs, (SELECT COUNT(*) FROM reactions WHERE comment_id = c.id AND reaction_type = 'heart') as hearts, (SELECT COUNT(*) FROM reactions WHERE comment_id = c.id AND reaction_type = 'pray') as prays, (SELECT COUNT(*) FROM reactions WHERE comment_id = c.id AND reaction_type = 'insight') as insights, (SELECT COUNT(*) FROM reactions WHERE comment_id = c.id AND reaction_type = 'clap') as claps FROM comments c JOIN users u ON c.user_id = u.id WHERE c.video_id = ? ORDER BY c.created_at DESC "); $stmt->execute([$video_id]); $comments = $stmt->fetchAll(); require_once 'includes/header.php'; ?>

Edit
views •

Comments

REPORT

Recommended

views