<?php
include("../../db.php");
//header("Access-Control-Allow-Origin: * ");
header('Content-Type: application/json');

$session = $_REQUEST['session'];
$class = $_REQUEST['class'];
$section = $_REQUEST['section'];

//   $session=mysql_real_escape_string($session);
//   $class=mysql_real_escape_string($class);

if (isset($_REQUEST['section']) && trim($_REQUEST['section']) != "") {
    $conwhere .= " and section='" . $_REQUEST['section'] . "' ";
}

$syllabus_table = getAppSyllabusTableName($db);

$result = $db->getRows("select * from $syllabus_table where session='$session' and class='$class' $conwhere ");

if ($result) {
    foreach ($result as $rowc) {
        $jsonc[] = "uploads/notice/" . $rowc['timetable_file'];

        $json['status'] = 1;
        $json['msg'] = "Data found Successfully..!";
        $json['data'] = $jsonc;
    }
    echo json_encode($json);
} else {
    echo json_encode(array('status' => 0, 'msg' => 'detail not found..!'));
}




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;
}