<?php
include 'C:\xampp\htdocs\admission_portal\includes\db.php';

// Check if setting exists
$check = $conn->query("SELECT * FROM system_settings WHERE setting_key = 'current_academic_year'");
if($check->num_rows == 0) {
    echo "Setting does not exist. Inserting...\n";
    $insert = $conn->query("INSERT INTO system_settings (setting_key, setting_value) VALUES ('current_academic_year', '2025')");
    if($insert) {
        echo "Inserted successfully.\n";
    } else {
        echo "Insert failed: " . $conn->error . "\n";
    }
} else {
    $row = $check->fetch_assoc();
    echo "Setting exists with value: " . $row['setting_value'] . "\n";
}

// Verify after insert/update
$res = $conn->query("SELECT setting_key, setting_value FROM system_settings WHERE setting_key = 'current_academic_year'");
if($res->num_rows > 0) {
    $row = $res->fetch_assoc();
    echo 'Current Academic Year in DB: ' . $row['setting_value'];
} else {
    echo 'No setting found';
}
$conn->close();
?>
