<?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 = file_get_contents('php://input');

$obj = json_decode($data, true);

$sql_c = "SELECT * FROM course_lesson_plan   WHERE course_lesson_plan_id='" . $obj["lesson"]["course_lesson_plan_id"] . "'   ";
$result_c = mysqli_query($conn, $sql_c);
if (mysqli_num_rows($result_c) > 0) {
    while ($row_c = mysqli_fetch_assoc($result_c)) {
        if (isset($obj["LessonTopic"])) {
            $sql_we = 'UPDATE course_lesson_plan SET
                lesson_topic= "' . $obj["LessonTopic"] . '"
            WHERE course_lesson_plan_id ="' . $row_c["course_lesson_plan_id"] . '"';

            if (mysqli_query($conn, $sql_we)) {
            }
        }
        if (isset($obj["LessonSubTopic"])) {
            $sql_we = 'UPDATE course_lesson_plan SET
                lesson_sub_topic= "' . $obj["LessonSubTopic"] . '"
            WHERE course_lesson_plan_id ="' . $row_c["course_lesson_plan_id"] . '"';

            if (mysqli_query($conn, $sql_we)) {
            }
        }
    }
    $curl_post_data = array(
        'Success' => 'true',
        'Reason' => 'You have succesfully Updated Lesson Topics'
    );
    echo json_encode($curl_post_data);
} else {
    $curl_post_data = array(
        'Success' => 'false',
        'Reason' => 'Unable to succesfully Lesson Topic, Contact Admin for help'
    );
    echo json_encode($curl_post_data);
}
