<?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();
$sql1 = "SELECT * FROM prerequisite_courses WHERE course_id='".$_GET[ 'course_id' ]."' ";
$result1 = mysqli_query( $conn, $sql1 );

if ( mysqli_num_rows( $result1 ) > 0 ) {
    while( $row1 = mysqli_fetch_assoc( $result1 ) ) {
        $course_name;
        $sql10 = "SELECT * FROM courses WHERE course_id='".$row1[ 'pre_requisite_course' ]."' ";
        $result10 = mysqli_query( $conn, $sql10 );

        if ( mysqli_num_rows( $result10 ) > 0 ) {
            while( $row10 = mysqli_fetch_assoc( $result10 ) ) {
                $course_name = $row10[ 'course_name' ];
            }
        }
        $curl_post_data = array(
            'prerequisite_id' => $row1[ 'prerequisite_id' ],
            'course_id' => $row1[ 'course_id' ],
            'pre_requisite_course' => $row1[ 'pre_requisite_course' ],
            'course_name' => $course_name,
            'dated' => $row1[ 'dated' ],
        );
        array_push( $data, $curl_post_data );
    }
}
echo json_encode( $data );
?>