connect_error) { die('Database Connection Failed: ' . $conn->connect_error); } // Fetch videos from database year($videos = []; $sql = "SELECT * FROM videos ORDER BY id DESC LIMIT 50"; $res = $conn->query($sql); if($res){ while($row = $res->fetch_assoc()){ $videos[] = [ 'title' => $row['title'], 'thumbnail' => $row['thumbnail'], 'views' => $row['views'], 'date' => $row['date'] ]; } } // index.php - Dark Video Grid (PHP version) // Safe/demo template inspired by the layout you provided. // ------------------------------------------------------- // Features: // - Single-file PHP template // - Video data driven by a PHP array (easy to replace with DB) // - Dark theme, responsive grid, header, search and categories // - Sections: Latest, Random, Most Viewed // - Replace the $videos array or follow the comments to connect to DB // ------------------------------------------------------- // Example video array. Replace thumbnail and url with your own. $videos = [ ['id'=>1,'title'=>'Sample Video 1','thumb'=>'https://via.placeholder.com/320x180?text=Video+1','url'=>'#','views'=>1200,'date'=>'2025-11-01'], ['id'=>2,'title'=>'Sample Video 2','thumb'=>'https://via.placeholder.com/320x180?text=Video+2','url'=>'#','views'=>800,'date'=>'2025-11-02'], ['id'=>3,'title'=>'Sample Video 3','thumb'=>'https://via.placeholder.com/320x180?text=Video+3','url'=>'#','views'=>450,'date'=>'2025-10-29'], ['id'=>4,'title'=>'Sample Video 4','thumb'=>'https://via.placeholder.com/320x180?text=Video+4','url'=>'#','views'=>3000,'date'=>'2025-10-20'], ['id'=>5,'title'=>'Sample Video 5','thumb'=>'https://via.placeholder.com/320x180?text=Video+5','url'=>'#','views'=>150,'date'=>'2025-11-10'], ['id'=>6,'title'=>'Sample Video 6','thumb'=>'https://via.placeholder.com/320x180?text=Video+6','url'=>'#','views'=>60,'date'=>'2025-11-12'], ['id'=>7,'title'=>'Sample Video 7','thumb'=>'https://via.placeholder.com/320x180?text=Video+7','url'=>'#','views'=>999,'date'=>'2025-09-30'], ['id'=>8,'title'=>'Sample Video 8','thumb'=>'https://via.placeholder.com/320x180?text=Video+8','url'=>'#','views'=>204,'date'=>'2025-11-05'], ['id'=>9,'title'=>'Sample Video 9','thumb'=>'https://via.placeholder.com/320x180?text=Video+9','url'=>'#','views'=>77,'date'=>'2025-11-11'], ['id'=>10,'title'=>'Sample Video 10','thumb'=>'https://via.placeholder.com/320x180?text=Video+10','url'=>'#','views'=>420,'date'=>'2025-10-25'], ]; // Helper functions function sort_by_date_desc($a,$b){ return strtotime($b['date']) - strtotime($a['date']); } function sort_by_views_desc($a,$b){ return $b['views'] - $a['views']; } $latest = $videos; usort($latest,'sort_by_date_desc'); $most_viewed = $videos; usort($most_viewed,'sort_by_views_desc'); $random = $videos; shuffle($random); // Pagination / limits for demo $latest_display = array_slice($latest,0,8); $random_display = array_slice($random,0,6); $most_viewed_display = array_slice($most_viewed,0,6); // Simple search handling (client-side could be added too) $search_query = isset($_GET['s']) ? trim($_GET['s']) : ''; if($search_query !== ''){ $search_lower = mb_strtolower($search_query); $filtered = array_filter($videos, function($v) use($search_lower){ return mb_stripos($v['title'],$search_lower) !== false; }); $latest_display = array_values($filtered); } ?> Dark Video Grid - Demo

Latest Videos

<?=htmlspecialchars($v['title'])?>

views ·

More Latest Videos

Random Videos

<?=htmlspecialchars($v['title'])?>

views

More Random Videos

Most Viewed Videos

<?=htmlspecialchars($v['title'])?>

views

More Most Viewed