<?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_10 = "select * from MentorStudentAssignment WHERE student_id='".$_GET[ 'student_id' ]."'     ";
        $result_10 = mysqli_query( $conn, $sql_10 );

        if ( mysqli_num_rows( $result_10 ) > 0 ) {
            while( $row_10 = mysqli_fetch_assoc( $result_10 ) ) {
                $sql="SELECT * FROM course_lesson_materials WHERE course_lesson_plan_id='".$row_10["course_lesson_plan_id"]."' ";
                $result = mysqli_query($conn, $sql);  
                if (mysqli_num_rows($result) > 0) {
                    while($row = mysqli_fetch_assoc($result)) {
                        $course_name;
                        $session;
                        $sql_clp="SELECT * FROM course_lesson_plan WHERE course_lesson_plan_id='".$row["course_lesson_plan_id"]."' ";
                        $result_clp = mysqli_query($conn, $sql_clp);  
                        if (mysqli_num_rows($result_clp) > 0) {
                            while($row_clp = mysqli_fetch_assoc($result_clp)) {
                                $sql_crs="SELECT * FROM courses WHERE course_id='".$row_clp["course_id"]."' ";
                                $result_crs = mysqli_query($conn, $sql_crs);  
                                if (mysqli_num_rows($result_crs) > 0) {
                                    while($row_crs = mysqli_fetch_assoc($result_crs)) {
                                        $course_name=$row_crs["course_name"];
                                        $session=$row_clp["lesson_session"];
                                    }
                                }
                            }
                        }
                 
                        $curl_post_data = array(
                            'course_lesson_materials_id' => $row["course_lesson_materials_id"] ,
                            'material_type' => $row["material_type"] ,
                            'material' => $row["material"] ,
                            'material_name' => $row["material_name"] ,
                            'course_name' => $course_name,
                            'session' => $session ,
                            'dated' => $row["dated"] ,
                        );
                        array_push($data, $curl_post_data );
                    }
                }
                $sql_1="SELECT * FROM course_lesson_materials_prev WHERE course_lesson_plan_id='".$row_10["course_lesson_plan_id"]."' ";
                $result_1 = mysqli_query($conn, $sql_1);  
                if (mysqli_num_rows($result_1) > 0) {
                    while($row_1 = mysqli_fetch_assoc($result_1)) {
                        $sql="SELECT * FROM course_lesson_materials WHERE course_lesson_materials_id='".$row_1["course_lesson_materials_id"]."' ";
                        $result = mysqli_query($conn, $sql);  
                        if (mysqli_num_rows($result) > 0) {
                            while($row = mysqli_fetch_assoc($result)) {
                                $course_name;
                                $session;
                                $sql_clp="SELECT * FROM course_lesson_plan WHERE course_lesson_plan_id='".$row["course_lesson_plan_id"]."' ";
                                $result_clp = mysqli_query($conn, $sql_clp);  
                                if (mysqli_num_rows($result_clp) > 0) {
                                    while($row_clp = mysqli_fetch_assoc($result_clp)) {
                                        $sql_crs="SELECT * FROM courses WHERE course_id='".$row_clp["course_id"]."' ";
                                        $result_crs = mysqli_query($conn, $sql_crs);  
                                        if (mysqli_num_rows($result_crs) > 0) {
                                            while($row_crs = mysqli_fetch_assoc($result_crs)) {
                                                $course_name=$row_crs["course_name"];
                                                $session=$row_clp["lesson_session"];
                                            }
                                        }
                                    }
                                }
                                $curl_post_data = array(
                                    'course_lesson_materials_id' => $row["course_lesson_materials_id"] ,
                                    'material_type' => $row["material_type"] ,
                                    'material' => $row["material"] ,
                                    'material_name' => $row["material_name"] ,
                                    'course_name' => $course_name,
                                    'session' => $session ,
                                    'dated' => $row["dated"] ,
                                );
                                array_push($data, $curl_post_data );
                            }
                        }
                    }
                }
            
               
            }
        }
 
echo json_encode( $data );
?>