<?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();

$sql_sfc = "select * from selfPacedAdultStudentAssignmentChecklist WHERE selfPacedAdultStudentAssignmentChecklist_id='" . $_GET["selfPacedAdultStudentAssignmentChecklist_id"] . "'  ";
$result_sfc = mysqli_query($conn, $sql_sfc);
if (mysqli_num_rows($result_sfc) > 0) {
    while ($row_sfc = mysqli_fetch_assoc($result_sfc)) {
        $Checked = "true";
        $Reason = "You have succesfully Added a Checklist item";
        if ($row_sfc["Checked"] === "true") {
            $Checked = "false";
            $Reason = "You have succesfully Unchecked a Checklist item";
        } else {
            $Checked = "true";
            $Reason = "You have succesfully Checked a Checklist item";
        }
        $sql_we = 'UPDATE selfPacedAdultStudentAssignmentChecklist SET Checked="' . $Checked . '"
                WHERE selfPacedAdultStudentAssignmentChecklist_id="' . $row_sfc["selfPacedAdultStudentAssignmentChecklist_id"] . '"
              ';

        if (mysqli_query($conn, $sql_we)) {
            $curl_post_data = array(
                'Success' => 'true',
                'Reason' =>  $Reason,
            );
            echo json_encode($curl_post_data);
        } else {
            $curl_post_data = array(
                'Success' => 'false',
                'Reason' => 'You were unable to succesfully Add a Checklist'
            );
            echo json_encode($curl_post_data);
        }
    }
}

      
// echo json_encode($data);
