<?php
include("../../db.php");
error_reporting(E_ALL);
header("Access-Control-Allow-Origin: * ");

$id = $_REQUEST['id'];

$syllabus_table = getAppSyllabusTableName($db);

$chkphoto = $db->getVal("select timetable_file from $syllabus_table where id='" . $id . "'");

if ($chkphoto != null) {

    unlink("../../uploads/notice/" . $chkphoto);


}

$flgUp = $db->delete($syllabus_table, "where id='$id'");

if ($flgUp != "") {
    echo json_encode(array('status' => 1, 'msg' => 'delete Successfully'));

} else {
    echo json_encode(array('status' => 0, 'msg' => 'image Not delete Please Try Again..!'));
}

function getAppSyllabusTableName($db){
    $table_name = "";

    $check_desc = $db->getVal("DESCRIBE app_syllabus");

    $check_desc_other = $db->getVal("DESCRIBE app_Syllabus");

    if ($check_desc == "id"){
        $table_name = "app_syllabus";
    }elseif ($check_desc_other == "id") {
        $table_name = "app_Syllabus";
    }

    return $table_name;
}