<?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();
    $i=0;
    $sql="SELECT * FROM curriculum ";
    $result = mysqli_query($conn, $sql);  
    if (mysqli_num_rows($result) > 0) {
        while($row = mysqli_fetch_assoc($result)) {
            $curriculumSession = array();
            $sql_1="SELECT * FROM curriculumEnrollment WHERE curriculum_id='".$row["curriculum_id"]."' AND Status='true'";
            $result_1 = mysqli_query($conn, $sql_1);  
            if (mysqli_num_rows($result_1) > 0) {
                while($row_1 = mysqli_fetch_assoc($result_1)) {
                    array_push($curriculumSession, $row_1);
                }
            }
            $curl_post_data = array(
                'Success' => 'true',
                'curriculum_id' => $row["curriculum_id"],
                'NoSessions' => $row["NoSessions"],
                'CurriculumName' => $row["CurriculumName"],
                'SessionName' => $row["SessionName"],
                'curriculumSession' => $curriculumSession ,
            );
            array_push($data, $curl_post_data);
            // array_push($data, $row);
        }
    }
    echo json_encode($data);
?>