<?php
// Attempt to connect to MySQL database //
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'Restax_final');

define('DB_PASSWORD', 'Restax_final123');

define('DB_NAME', 'Restax_api_data'); 
 

$con = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);  


 $course=$request->getAttribute('course');
 $department=$request->getAttribute('department');
 $level_id=$request->getAttribute('level_id');
  $batch=$request->getAttribute('batch');



		
$response=array();

//Active Student


if(isset($course)&&isset($department)&&isset($level_id)&&isset($batch)){
	$sql12="SELECT * FROM student WHERE course='$course' AND level_id='$level_id' AND department='$department' AND batch='$batch'AND status = '1'";
}
elseif(isset($course)&&isset($department)&&isset($level_id)){
	$sql12="SELECT * FROM student WHERE course='$course' AND level_id='$level_id' AND department='$department'AND status = '1'";
}
elseif(isset($course)&&isset($department)){
	$sql12="SELECT * FROM student WHERE course='$course' AND department='$department'AND status = '1'";
}
elseif(isset($course)){
	$sql12="SELECT * FROM student WHERE course='$course'AND status = '1'";
	echo "hai";
}
else{
	$sql12="SELECT * FROM student WHERE status = '1'";
}

$res= $con->query($sql12);


while ($row[]=mysqli_fetch_assoc($res)) {  

      $active_student=count($row);

    }

//Non Active Student

if(isset($course)&&isset($department)&&isset($level_id)&&isset($batch)){
	$sql15="SELECT * FROM student WHERE course='$course' AND level_id='$level_id' AND department='$department' AND batch='$batch'AND status = '0'";
}
elseif(isset($course)&&isset($department)&&isset($level_id)){
	$sql15="SELECT * FROM student WHERE course='$course' AND level_id='$level_id' AND department='$department'AND status = '0'";
}
elseif(isset($course)&&isset($department)){
	$sql15="SELECT * FROM student WHERE course='$course' AND department='$department'AND status = '0'";
}
elseif(isset($course)){
	$sql15="SELECT * FROM student WHERE course='$course'AND status = '0'";
}
else{
	$sql15="SELECT * FROM student WHERE status = '0'";
}


$res15= $con->query($sql15);

    while ($row15[]=mysqli_fetch_assoc($res15)) {  

      $non_active_student=count($row15);

    }


	$data=array('name' =>$type, );


	    // $message=$data;

		

	$response=array('status' => "true",'Message' => "Data inserted successfully",$user);

echo $datawelcome='[{"Total_arctive_student":"'.$active_student.'","Archived_student":"'.$non_active_student.'"}]';




?>