<?php

include '../db.php'; 



$data = json_decode(file_get_contents('php://input'), true);



if (isset($data['q_id']) && isset($data['q_solution'])) {

    $q_id = mysqli_real_escape_string($con, $data['q_id']);

    $q_solution = mysqli_real_escape_string($con, $data['q_solution']);



    $update_query = "UPDATE query_table SET q_solution = '$q_solution' WHERE q_id = '$q_id'";

    if (mysqli_query($con, $update_query)) {

        echo "Solution updated successfully.";

    } else {

        echo "Failed to update solution: " . mysqli_error($con);

    }

} else {

    echo "Invalid input.";

}



mysqli_close($con);

?>