Discovery Hub
Explore the best student-led innovation across the network.
prepare("SELECT * FROM users WHERE id = ?"); $stmt->execute([$current_user_id]); $user = $stmt->fetch(); if (!$user) { session_destroy(); header("Location: login.php"); exit; } $user_role = $user['role']; // Blocked users filter $stmt = db()->prepare("SELECT blocked_id FROM blocked_users WHERE blocker_id = ?"); $stmt->execute([$current_user_id]); $blocked_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); $stmt = db()->prepare("SELECT blocker_id FROM blocked_users WHERE blocked_id = ?"); $stmt->execute([$current_user_id]); $blocked_by_ids = $stmt->fetchAll(PDO::FETCH_COLUMN); $all_blocked = array_unique(array_merge($blocked_ids, $blocked_by_ids)); $placeholders = empty($all_blocked) ? "0" : implode(',', array_fill(0, count($all_blocked), '?')); // Leaderboard: Most Followed This Week $sql = " SELECT s.id, s.name, s.description, u.full_name as founder_name, COUNT(sf.id) as followers_count FROM startups s JOIN users u ON s.founder_id = u.id JOIN startup_followers sf ON s.id = sf.startup_id WHERE sf.created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) AND u.id NOT IN ($placeholders) GROUP BY s.id ORDER BY followers_count DESC LIMIT 10 "; $stmt = db()->prepare($sql); $stmt->execute($all_blocked ?: []); $mostFollowed = $stmt->fetchAll(); // Leaderboard: Most Funded This Week $sql = " SELECT s.id, s.name, s.description, u.full_name as founder_name, SUM(i.amount) as funded_amount FROM startups s JOIN users u ON s.founder_id = u.id JOIN investments i ON s.id = i.startup_id WHERE i.status = 'approved' AND i.created_at >= DATE_SUB(NOW(), INTERVAL 7 DAY) AND u.id NOT IN ($placeholders) GROUP BY s.id ORDER BY funded_amount DESC LIMIT 10 "; $stmt = db()->prepare($sql); $stmt->execute($all_blocked ?: []); $mostFunded = $stmt->fetchAll(); // Search logic $q = $_GET['q'] ?? ''; $browseStartups = []; $where = "s.status = 'public' AND u.id NOT IN ($placeholders)"; $params = $all_blocked ?: []; if ($q) { $where .= " AND (s.name LIKE ? OR s.description LIKE ? OR u.full_name LIKE ?)"; $params[] = "%$q%"; $params[] = "%$q%"; $params[] = "%$q%"; } $stmt = db()->prepare(" SELECT s.*, u.full_name as founder_name FROM startups s JOIN users u ON s.founder_id = u.id WHERE $where ORDER BY s.created_at DESC LIMIT 20 "); $stmt->execute($params); $browseStartups = $stmt->fetchAll(); $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; ?>
Explore the best student-led innovation across the network.