<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
include '../../../config/index.php';
$data = array();
$data = json_decode(file_get_contents('php://input'), true);
$sql = "SELECT * FROM TotCurriculumSettings ";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {

        $sql_two = "UPDATE TotCurriculumSettings SET
                curriculum_id='" . $_GET["curriculum_id"] . "',
                module_id='" . $_GET["module_id"] . "',
                package_id='" . $_GET["package_id"] . "'
                WHERE TotCurriculumSettingsID='" . $row["TotCurriculumSettingsID"] . "'
                ";  
        if (mysqli_query($conn, $sql_two)) {

            $new_array = array(
                'Success' => "true",
                'Reason' => "You have succesfully Updated settings",


            );
            echo json_encode($new_array);

        } else {
            $new_array = array(
                'Success' => "false",
                'Reason' => "You were unable to succesfully Update settings",

            );
            echo json_encode($new_array);
        }
    }
} else {

    $sql_two = "INSERT INTO TotCurriculumSettings VALUES(NULL,
      
       '" . $_GET["curriculum_id"] . "',
         '" . $_GET["module_id"] . "', 
         '" . $_GET["package_id"] . "', 
          now() )"; 
    if (mysqli_query($conn, $sql_two)) {
        $new_array = array(
            'Success' => "true",
            'Reason' => "You have succesfully Updated settings",


        );
        echo json_encode($new_array);

    } else {
        $new_array = array(
            'Success' => "false",
            'Reason' => "You were unable to succesfully Update settings",

        );
        echo json_encode($new_array);
    }


}

?>