This commit is contained in:
Flatlogic Bot 2026-02-28 18:56:22 +00:00
parent 03c203ff92
commit d9eba63b0d
4 changed files with 40 additions and 8 deletions

View File

@ -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);

View File

@ -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();
<?= htmlspecialchars(substr($s['description'], 0, 100)) ?>...
</p>
<div style="display: flex; justify-content: space-between; align-items: center;">
<span class="badge" style="font-size: 10px;"><?= ucfirst($s['industry']) ?></span>
<?php if (!empty($s['industry'])): ?>
<span class="badge" style="font-size: 10px;"><?= htmlspecialchars($s['industry']) ?></span>
<?php endif; ?>
<span style="font-weight: 700; color: var(--accent-blue);">£<?= number_format($s['funding_raised']) ?></span>
</div>
</div>

View File

@ -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';
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Startup Name</label>
<input type="text" name="name" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Industry</label>
<select name="industry" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff;">
<option value="">Select Industry</option>
<option value="Fintech">Fintech</option>
<option value="Healthtech">Healthtech</option>
<option value="Edtech">Edtech</option>
<option value="E-commerce">E-commerce</option>
<option value="SaaS">SaaS</option>
<option value="Clean Energy">Clean Energy</option>
<option value="AI & Robotics">AI & Robotics</option>
<option value="Other">Other</option>
</select>
</div>
<div style="margin-bottom: 15px;">
<label style="display: block; margin-bottom: 8px; font-size: 14px; font-weight: 500;">Description</label>
<textarea name="description" required style="width: 100%; padding: 12px; border-radius: 12px; background: var(--surface-color); border: 1px solid var(--border-color); color: #fff; height: 120px; resize: none;"></textarea>

View File

@ -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) {
<script src="assets/js/main.js"></script>
</body>
</html>
</html>