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

$id = $_REQUEST['id'];

$att_cl_ctr = $db->getVal("select teacher_att_class_ctr from tbl_info where id='1' ");

if ($att_cl_ctr == '2') {
    $sqlsec = "select distinct(section) from Attandence_role where teacher_id='$id'";
    $result1 = mysql_query($sqlsec);

    while ($rowc = mysql_fetch_assoc($result1)) {

        $jsonc[] = $rowc['section'];


    }


    if ($jsonc[0] == '') {
        $jsonc = array();
    }


    $sql = "select distinct(class) from Attandence_role where teacher_id='$id'";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_assoc($result)) {


        $jsonn[] = $row['class'];
        $json['status'] = 1;
        $json['msg'] = "successful";
        $json['data'] = array("class" => $jsonn, "section" => $jsonc, "att_cl_ctr" => $att_cl_ctr);
        //	$json['section']=$jsonc;

    }


}

if ($att_cl_ctr == '1') {


    $sqlsec = "select name from section";

    $result1 = mysql_query($sqlsec);
    while ($rowc = mysql_fetch_assoc($result1)) {


        $jsonc[] = $rowc['name'];


    }

    $sqlsec = "select name,total from examterm";
    $result_term = mysql_query($sqlsec);
    while ($rowt = mysql_fetch_assoc($result_term)) {


        $jsond[] = array("exam_name" => $rowt['name'], "max_mark" => $rowt['total']);


    }

    $sql = "select class from class";

    $result = mysql_query($sql);
    while ($row = mysql_fetch_assoc($result)) {


        $jsonn[] = $row['class'];
        $json['status'] = 1;
        $json['msg'] = "successful";
        $json['data'] = array("class" => $jsonn, "section" => $jsonc, "exam_term" => $jsond, "att_cl_ctr" => $att_cl_ctr);


    }

}

if (empty($json)) {
    $json['status'] = 0;
    $json['msg'] = "data not found";
}

echo json_encode($json);
?>