 <?php
include("../../db.php");
header("Access-Control-Allow-Origin: * ");
header('Content-Type: application/json');
 
 
        $class=$_REQUEST['class'];
        $session=$_REQUEST['session'];
        // $class=mysql_real_escape_string($class);
        // $session=mysql_real_escape_string($session);
		$section=$_REQUEST['section'];




$result_term = $db->getRows("select s.idno,s.department,s.name,s.experience,s.photo,e.class,e.teacher_id,e.session from staff as s inner join assign_teacher as e on s.idno=e.teacher_id where e.class='$class' and section='$section' and e.session='$session' and e.is_class_teacher='0'");
//echo $SS="select s.idno,s.department,s.name,s.experience,s.photo,e.class,e.teacher_id,e.session from staff as s inner join assign_teacher as e on s.idno=e.teacher_id where e.class='$class' $conwhere and e.session='$session' and e.is_class_teacher='0'";
//   while ($rowt = mysql_fetch_assoc($result_term)) 	
    foreach($result_term as $rowt)
	{
	    
	
	
    	$jsond[]=array("id"=>$rowt['idno'],"name"=>$rowt['name'],"subject"=>$rowt['experience'],"photo"=>"media/photo/".$rowt['photo']);
 	    
	    
	}
	
	
$result_teacher = $db->getRows("select s.idno,s.department,s.name,s.experience,s.photo,e.class,e.teacher_id,e.session from staff as s inner join assign_teacher as e on s.idno=e.teacher_id where e.class='$class' and section='$section' and e.session='$session' and e.is_class_teacher='1'");

//echo $s="select s.idno,s.department,s.name,s.experience,s.photo,e.class,e.teacher_id,e.session from staff as s inner join assign_teacher as e on s.idno=e.teacher_id where e.class='$class' $conwhere and e.session='$session' and e.is_class_teacher='1'";

//   while($row = mysql_fetch_assoc($result_teacher)) 	
    foreach($result_teacher as $row)
	{
 	  
		$classteacher=array("id"=>$row['idno'],"name"=>$row['name'],"subject"=>$row['experience'],"photo"=>"media/photo/".$row['photo']);

	}
if(empty($classteacher))
{
          $json['status']=1;
		 $json['msg']="successful";
		 $json['data']=array("class_teacher" =>"","subject_teacher"=>$jsond);   
}
else
{
         $json['status']=1;
		 $json['msg']="successful";
		 $json['data']=array("class_teacher" =>$classteacher,"subject_teacher"=>$jsond);      
}

        


	
if(is_array($json) && count($json)>0)
	{  
		echo json_encode($json);    
			
	}else
	{		
	 	echo json_encode(array('status' => 0, 'msg'=>'data not found..!'));
	}

       
	


?>