From d9eba63b0df804d0790cd00bc68a7b255f98fd16 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Sat, 28 Feb 2026 18:56:22 +0000 Subject: [PATCH] v26 --- .../10_add_missing_startup_fields.sql | 7 +++++++ discover.php | 10 +++++---- start_funding.php | 21 ++++++++++++++++--- startup_details.php | 10 ++++++++- 4 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 db/migrations/10_add_missing_startup_fields.sql diff --git a/db/migrations/10_add_missing_startup_fields.sql b/db/migrations/10_add_missing_startup_fields.sql new file mode 100644 index 0000000..afda358 --- /dev/null +++ b/db/migrations/10_add_missing_startup_fields.sql @@ -0,0 +1,7 @@ +-- Migration: Add missing fields to startups table for Discovery Hub and Details page +ALTER TABLE startups +ADD COLUMN industry VARCHAR(100) AFTER description, +ADD COLUMN followers_count INT DEFAULT 0 AFTER status; + +-- Initialize followers_count from existing startup_followers table +UPDATE startups s SET followers_count = (SELECT COUNT(*) FROM startup_followers WHERE startup_id = s.id); diff --git a/discover.php b/discover.php index 80a9a70..d3f3e74 100644 --- a/discover.php +++ b/discover.php @@ -19,7 +19,7 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; // Leaderboard: Most Followed $stmt = db()->query(" - SELECT s.*, u.full_name as founder_name, s.followers_count + SELECT s.*, u.full_name as founder_name FROM startups s JOIN users u ON s.founder_id = u.id ORDER BY s.followers_count DESC @@ -39,7 +39,7 @@ $mostFunded = $stmt->fetchAll(); // General Browse $q = $_GET['q'] ?? ''; -$where = "onboarding_completed = 1"; +$where = "u.onboarding_completed = 1"; $params = []; if ($q) { $where .= " AND (s.name LIKE ? OR s.description LIKE ? OR s.industry LIKE ?)"; @@ -49,7 +49,7 @@ if ($q) { } $stmt = db()->prepare(" - SELECT s.*, u.full_name as founder_name + SELECT s.*, u.full_name as founder_name FROM startups s JOIN users u ON s.founder_id = u.id WHERE $where @@ -187,7 +187,9 @@ $browseStartups = $stmt->fetchAll(); ...

- + + + £
diff --git a/start_funding.php b/start_funding.php index 047e26d..37001c0 100644 --- a/start_funding.php +++ b/start_funding.php @@ -34,10 +34,11 @@ if ($startup_id > 0) { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $name = trim($_POST['name'] ?? ''); $description = trim($_POST['description'] ?? ''); + $industry = trim($_POST['industry'] ?? ''); $target = (float)($_POST['funding_target'] ?? 0); $status = $_POST['status'] ?? 'public'; - if ((!$existingStartup && empty($name)) || (!$existingStartup && empty($description)) || $target < 50) { + if ((!$existingStartup && (empty($name) || empty($description) || empty($industry))) || $target < 50) { $error = "Please fill in all required fields. Minimum target is £50."; } else { db()->beginTransaction(); @@ -49,8 +50,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $final_id = $existingStartup['id']; } else { // 1. Insert startup - $stmt = db()->prepare("INSERT INTO startups (name, description, founder_id, funding_target, status) VALUES (?, ?, ?, ?, ?)"); - $stmt->execute([$name, $description, $_SESSION['user_id'], $target, $status]); + $stmt = db()->prepare("INSERT INTO startups (name, description, industry, founder_id, funding_target, status) VALUES (?, ?, ?, ?, ?, ?)"); + $stmt->execute([$name, $description, $industry, $_SESSION['user_id'], $target, $status]); $new_startup_id = db()->lastInsertId(); // 2. Insert initial funding round @@ -106,6 +107,20 @@ $platformName = defined('PLATFORM_NAME') ? PLATFORM_NAME : 'Gatsby'; +
+ + +
diff --git a/startup_details.php b/startup_details.php index 28c4336..21b6456 100644 --- a/startup_details.php +++ b/startup_details.php @@ -31,10 +31,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action'])) { if ($_POST['action'] === 'follow') { $stmt = db()->prepare("INSERT IGNORE INTO startup_followers (user_id, startup_id) VALUES (?, ?)"); $stmt->execute([$user_id, $startup_id]); + if ($stmt->rowCount() > 0) { + $stmt = db()->prepare("UPDATE startups SET followers_count = followers_count + 1 WHERE id = ?"); + $stmt->execute([$startup_id]); + } $success = "You are now following " . $startup['name'] . "!"; } elseif ($_POST['action'] === 'unfollow') { $stmt = db()->prepare("DELETE FROM startup_followers WHERE user_id = ? AND startup_id = ?"); $stmt->execute([$user_id, $startup_id]); + if ($stmt->rowCount() > 0) { + $stmt = db()->prepare("UPDATE startups SET followers_count = GREATEST(0, followers_count - 1) WHERE id = ?"); + $stmt->execute([$startup_id]); + } $success = "You have unfollowed " . $startup['name'] . "."; } elseif ($_POST['action'] === 'invest' && $user['role'] === 'investor') { $amount = (float)($_POST['amount'] ?? 0); @@ -451,4 +459,4 @@ if ($canSeeHistory) { - + \ No newline at end of file