<?php
// cleanup_and_insert_test_bonus.php
session_start();
require("config.php");
require("db.php");

// ===== EMPTY THE TABLE =====
$truncateQuery = "TRUNCATE TABLE top_investor_updates";
if (mysqli_query($db, $truncateQuery)) {
    echo "✅ Table cleared successfully.<br>";
} else {
    echo "❌ Failed to clear table: " . mysqli_error($db) . "<br>";
}

// ===== INSERT FRESH TEST BONUS =====
$user_id = 18; // your test user ID
$insertQuery = "
INSERT INTO top_investor_updates 
(user_id, update_title, update_message, bonus_amount, bonus_expiry, created_at, total_bonus_claimed, lost_bonus)
VALUES 
($user_id, 'New Weekly Bonus', 'Fresh test bonus after cleanup', 15.00, DATE_ADD(NOW(), INTERVAL 3 MINUTE), NOW(), 0, 0)
";

if (mysqli_query($db, $insertQuery)) {
    echo "✅ Fresh test bonus inserted successfully.";
} else {
    echo "❌ Failed to insert test bonus: " . mysqli_error($db);
}

?>
