<?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_two = 'UPDATE  AdultStudents SET
        FirstName="' . $_GET["learner_name"] . '",
        LastName="' . $_GET["learner_last_name"] . '",
        Email="' . $_GET["username"] . '",
        PhoneNumber="' . $_GET["PhoneNumber"] . '",
        DateOfBirth="' . $_GET["learner_age"] . '"
        WHERE AdultStudent_id="' . $_GET["AdultStudent_id"] . '"';

if (mysqli_query($conn, $sql_two)) {
    $sql = "select * from AdultStudents   WHERE AdultStudent_id='" . $_GET["AdultStudent_id"] . "' ";
    $result = mysqli_query($conn, $sql);
    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_assoc($result)) {


            $Type = "tot";
            $class_name = "";
            $center_name = "";


            $SelfpacedCourse = "false";
            $SelfpacedClass = "Quest";
            $sql_cc = "select * from selfPacedAdultStudent   WHERE AdultStudent_id='" . $row["AdultStudent_id"] . "'";
            $result_cc = mysqli_query($conn, $sql_cc);
            if (mysqli_num_rows($result_cc) > 0) {
                $SelfpacedCourse = "true";
                $SelfpacedClass = "Thrive";
            }
            $new_array = array(
                'Success' => "true",
                'Reason' => "You Have Succesfully Updated Learner Details",
                'User' => "Learner",
                'user_id' => $row["AdultStudent_id"],
                'Email' => $row["Email"],
                'FirstName' => $row["FirstName"],
                'LastName' =>  $row["LastName"],
                'PhoneNumber' =>   $row["PhoneNumber"],
                'Type' =>   $Type,
                'class_name' =>   $class_name,
                'center_name' =>   $center_name,
                'Age' =>    $row["DateOfBirth"],
                'centerClasses_id' => $row["centerClasses_id"],
                'dated' => $row["dated"],
                'Image' => $row['Image'],
                'Supervisor' => "",
                'External' => "",
                'Location' => "",
                'Physical' => "",
                'Transport' => "",
                'Approved' => "",
                'NewParent' => "false",
                'Status' => "Active",
                'SelfpacedCourse' => $SelfpacedCourse,
                'SelfpacedClass' => $SelfpacedClass,
                'dated' => $row["dated"],

            );
            // array_push($data, $new_array);
            echo json_encode($new_array);
        }
    }
} else {
    $new_array = array(
        'Success' => "false",
        'Reason' => "Something went wrong. Please Try Again Later",
        'AdultStudent_id' => $_GET["AdultStudent_id"],
    );
    echo json_encode($new_array);
}
