<?php 
include('../include/config.php');
if(!empty($_POST["id"])) 
{
    $cnt= $_POST["id"];
    $eid= $_POST["eid"];
    
$query=mysqli_query($con,"select * from MarksScore where PID='$cnt' AND EID='$eid'");
$num=mysqli_fetch_array($query);
if($num>0)
{
  $result =mysqli_query($con,"SELECT pupils.*,Classteachers.Teacher as tc,Staffs.Name as nm, MarksScore.Lang as lang,MarksScore.Comp as com,MarksScore.Lugha as lugg,MarksScore.Insha as ins,MarksScore.Maths as mat,MarksScore.Scie as sia,MarksScore.SS as ss,MarksScore.CRE as cre, MarksScore.Remark as rema from pupils left join Classteachers ON Classteachers.Clazzz=pupils.Claz left join Staffs ON Staffs.id=Classteachers.Teacher left join MarksScore ON MarksScore.PID=pupils.count where pupils.count='$cnt' AND MarksScore.EID='$eid'");
    $row=mysqli_fetch_array($result);
    echo json_encode($row);  
    
}else
{
    $result =mysqli_query($con,"SELECT pupils.*,Classteachers.Teacher as tc,Staffs.Name as nm from pupils left join Classteachers ON Classteachers.Clazzz=pupils.Claz left join Staffs ON Staffs.id=Classteachers.Teacher where pupils.count='$cnt'");
    $row=mysqli_fetch_array($result);
    echo json_encode($row);
}
    }else
    {
      echo "Not found";
    }

?>