<?php include("parent/callMe.php"); ?>

<?php
$id=$_REQUEST['branch'];

$sql = "SELECT sec.*, cls.* FROM edu_adm_section_detail as sec LEFT JOIN edu_class_config as cls ON sec.class_id = cls.class_id where cls.class_id!='' and cls.branch_id='$id' and sec.branch_id='$id' ORDER BY sec.class_order asc";
$classes_sections = $m->query($sql);

$data=array();
foreach ($classes_sections as $cls_sec) {

$clsID=$cls_sec['class_id'];
$secID=$cls_sec['section_id'];
$sessionIDs=$_SESSION['current_session'];
$query="SELECT student_id,first_name,last_name,candidate_roll_no,ref_no,cell_no,class_id,section_id,status,branch_id FROM edu_student_details where class_id='$clsID' and status='0' and section_id='$secID' /*and session_id='$sessionIDs'*/ and branch_id='$id'";
  $students_data = $m->query($query);

 //echo $query;  
     $data[$cls_sec['class_id'].$cls_sec['section_id']]=$students_data;
 
    
}

//echo"<pre>";print_r($data);echo"<pre>";


//echo $student['class_id']."<br>";

/*$query="SELECT student_id,first_name,last_name,candidate_roll_no,ref_no,cell_no,class_id FROM edu_student_details where class_id=".$student['class_id'];
$classes = $m->query($query);

foreach ($classes as $class) {
    $data[$class['class_id']]=$class;
}*/
    /*for ($i=0 ; $i < count($student['class_id']) ; $i++ ) { 
        
       $data[$student['class_id']]=$student;
    }*/

    
 //$data[$student['class_id']]=$student;

//}

  //echo"<pre>";print_r($data);echo"<pre>";
 echo json_encode($data);
?>

	 
