 <?php
include("../../db.php");
header("Access-Control-Allow-Origin: * ");
header('Content-Type: application/json');
 
       $class=$_REQUEST['class'];
	   $teacher_id=mysql_real_escape_string(($_REQUEST['teacher_id']));
       $session=$_REQUEST['session'];
       $class=mysql_real_escape_string($class);
       $session=mysql_real_escape_string($session);
 
   //$result =$db->getRows("select subject from subject where class='$class' and session='$session'");
   
   $teacher_control= $db->getVal("select teacher_sub_control from tbl_info where id='1'");

   if($teacher_control=='1'){
	   
    $result =$db->getRows("select id,subject from subject where  class='$class' and session='$session'");
	 

   }
   if ($teacher_control=='2'){
	   
	    $result =$db->getRows("select id,subject from subject where id in (select cls_sub_id from teacher_subject where teacher_id='$teacher_id' and  session='$session') and class='$class' and session='$session'");

		
	 }
	
		if($result)
		{
   foreach ($result as $row) 	
	{
    	$jsonn[]=$row['subject'];
 	    $json['status']=1;
		$json['msg']="successful";
		$json['data']=$jsonn;
	//	$json['section']=$jsonc;	    
	}
echo json_encode($json);	
}
else
{

    echo json_encode(array('status' => 0, 'msg'=>'detail not found..!'));
}
?>