Edit Profile
+ Back to DashboardManage your public presence in the = htmlspecialchars($platformName) ?> community.
= htmlspecialchars($error) ?>
diff --git a/generate_startup_content.php b/generate_startup_content.php
index f276eba..4413e97 100644
--- a/generate_startup_content.php
+++ b/generate_startup_content.php
@@ -87,7 +87,7 @@ function simulate_funding_progress() {
continue;
}
- $status = (rand(0, 10) > 2) ? 'approved' : 'pending'; // 80% chance of being approved
+ $status = 'approved'; // 80% chance of being approved
$stmt = $db->prepare("INSERT INTO investments (investor_id, startup_id, funding_round_id, amount, status, created_at)
VALUES (:iid, :sid, :frid, :amount, :status, :created)");
diff --git a/invest.php b/invest.php
index 25b10dc..ffea442 100644
--- a/invest.php
+++ b/invest.php
@@ -47,7 +47,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Actually let's look at the database schema for investments
$equity_pct = 0.00; // Mock logic for equity
- $stmt = db()->prepare("INSERT INTO investments (startup_id, investor_id, funding_round_id, amount, equity_pct, status) VALUES (?, ?, ?, ?, ?, 'pending')");
+ $stmt = db()->prepare("INSERT INTO investments (startup_id, investor_id, funding_round_id, amount, equity_pct, status) VALUES (?, ?, ?, ?, ?, 'approved')");
$stmt->execute([$startupId, $investor_id, $startup['round_id'], $amount, $equity_pct]);
// 2. Update funding_rounds raised amount
@@ -59,7 +59,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$stmt->execute([$amount, $startupId]);
db()->commit();
- $success = "Investment of £" . number_format($amount) . " submitted successfully! The founder will be notified.";
+ $success = "Investment of £" . number_format($amount) . " confirmed successfully!";
header("refresh:3;url=portfolio.php");
} catch (Exception $e) {
db()->rollBack();
diff --git a/sync_funding.php b/sync_funding.php
index 4deb479..ff0fb6c 100644
--- a/sync_funding.php
+++ b/sync_funding.php
@@ -7,22 +7,26 @@ echo "Recalculating funding totals...\n";
db()->exec("UPDATE startups SET funding_raised = 0");
db()->exec("UPDATE funding_rounds SET funding_raised = 0");
-// 2. Fetch all approved/pending investments (usually we only count approved, but let's see)
-// Actually, let's count all investments that are not rejected
-$stmt = db()->query("SELECT startup_id, funding_round_id, SUM(amount) as total FROM investments WHERE status != 'rejected' GROUP BY startup_id, funding_round_id");
-$totals = $stmt->fetchAll();
+// 2. Update funding_rounds totals
+$stmt = db()->query("SELECT funding_round_id, SUM(amount) as total FROM investments WHERE status != 'rejected' GROUP BY funding_round_id");
+$roundTotals = $stmt->fetchAll();
-foreach ($totals as $t) {
- echo "Updating Startup ID: {$t['startup_id']}, Round ID: {$t['funding_round_id']} with £{$t['total']}\n";
-
- // Update funding_rounds
+foreach ($roundTotals as $t) {
+ if (!$t['funding_round_id']) continue;
+ echo "Updating Round ID: {$t['funding_round_id']} with £{$t['total']}\n";
$stmt2 = db()->prepare("UPDATE funding_rounds SET funding_raised = ? WHERE id = ?");
$stmt2->execute([$t['total'], $t['funding_round_id']]);
-
- // Update startups
+}
+
+// 3. Update startups totals (sum of all their rounds)
+$stmt = db()->query("SELECT startup_id, SUM(amount) as total FROM investments WHERE status != 'rejected' GROUP BY startup_id");
+$startupTotals = $stmt->fetchAll();
+
+foreach ($startupTotals as $t) {
+ if (!$t['startup_id']) continue;
+ echo "Updating Startup ID: {$t['startup_id']} with £{$t['total']}\n";
$stmt3 = db()->prepare("UPDATE startups SET funding_raised = ? WHERE id = ?");
$stmt3->execute([$t['total'], $t['startup_id']]);
}
-echo "Done!\n";
-
+echo "Done!\n";
\ No newline at end of file