<?php
// Assuming you have a database connection script (e.g., shikanisha.kts.php)
require('shikanisha.kts.php');

if (isset($_POST['session_id']) && isset($_POST['updated_cost'])) {
    $sessionId = $_POST['session_id'];
    $updatedCost = $_POST['updated_cost'];

    // Update the cost in the database (replace with your actual SQL query)
    $sql = "UPDATE swimming SET cost = $updatedCost WHERE swimid = $sessionId";
    $result = $conn->query($sql);

    if ($result) {
        $response = array("success" => true);
    } else {
        $response = array("success" => false);
    }

    // Close the database connection
    $conn->close();

    // Send JSON response back to the JavaScript
    header('Content-Type: application/json');
    echo json_encode($response);
} else {
    // Handle case where session_id or updated_cost is not provided
    $response = array("success" => false);
    header('Content-Type: application/json');
    echo json_encode($response);
}
?>
