<?php
include("../../db.php");
header('Content-Type: application/json');

$teacher_id_param = $_POST['teacher_id'];
$fileJS = $_POST['file'];
$session = $_POST['session'];

$status = 0;
$msg = '';


$teacher_id_list = json_decode($teacher_id_param, true);

foreach ($teacher_id_list as $teacher_id) {

    $file_aray = json_decode($fileJS, true);

    foreach ($file_aray as $file) {

        if ($teacher_id != "" || $file != "" || $session != "") {
            $ary = array(
                "teacher_id" => "$teacher_id",
                "file" => "$file",
                "session" => "$session"
            );
        }
        $flgIn = $db->insertAry("teacher_timetable", $ary);

        if ($flgIn > 0) {
            $status = 1;
            $msg = "Data inserted successfully.";
        } else {
            $msg = "Something went wrong. Please try again.";
        }

    }


}

echo json_encode(array('status' => $status, 'msg' => "$msg"));

?>