prepare("SELECT s.*, u.full_name as founder_name FROM startups s JOIN users u ON s.founder_id = u.id WHERE s.id = ?"); $stmt->execute([$startup_id]); $startup = $stmt->fetch(); if (!$startup) { header('Location: startups.php'); exit; } // Fetch funding history $stmt = db()->prepare("SELECT i.*, u.full_name as investor_name FROM investments i JOIN users u ON i.investor_id = u.id WHERE i.startup_id = ? ORDER BY i.created_at DESC"); $stmt->execute([$startup_id]); $fundingHistory = $stmt->fetchAll(); // Check if user is the founder $isFounder = isset($_SESSION['user_id']) && $_SESSION['user_id'] == $startup['founder_id']; $isInvestor = isset($_SESSION['user_id']) && $_SESSION['role'] === 'investor'; // For investors, check if they can see history (maybe only after some interaction?) // For now, let everyone see. $canSeeHistory = true; // Handle following $isFollowing = false; if (isset($_SESSION['user_id'])) { $stmt = db()->prepare("SELECT 1 FROM startup_followers WHERE startup_id = ? AND user_id = ?"); $stmt->execute([$startup_id, $_SESSION['user_id']]); $isFollowing = (bool)$stmt->fetch(); } if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { if (!isset($_SESSION['user_id'])) { header('Location: login.php'); exit; } if ($_POST['action'] === 'follow') { if ($isFollowing) { $stmt = db()->prepare("DELETE FROM startup_followers WHERE startup_id = ? AND user_id = ?"); $stmt->execute([$startup_id, $_SESSION['user_id']]); $stmt = db()->prepare("UPDATE startups SET followers_count = followers_count - 1 WHERE id = ?"); $stmt->execute([$startup_id]); } else { $stmt = db()->prepare("INSERT INTO startup_followers (startup_id, user_id) VALUES (?, ?)"); $stmt->execute([$startup_id, $_SESSION['user_id']]); $stmt = db()->prepare("UPDATE startups SET followers_count = followers_count + 1 WHERE id = ?"); $stmt->execute([$startup_id]); } header("Location: startup_details.php?id=$startup_id"); exit; } } ?>
= nl2br(htmlspecialchars($startup['product_service'])) ?>
= htmlspecialchars($startup['business_model']) ?>
= htmlspecialchars($startup['operational_stage']) ?>
No investment history available yet.