<?php
include("../../db.php");
header('Content-Type: application/json');

$status = 0;
$msg = "Unable to fetch data..! Please retry later";
$data = array();

if (isset($_GET['session'])){

    $session    = $_GET['session'];

    $result = $db->getRows("SELECT t1.*,DATE_FORMAT(t1.date, '%d-%m-%Y') AS date,t2.name AS teacher_name FROM teacher_task_report t1 LEFT JOIN staff t2 ON t1.teacher_id = t2.idno WHERE t1.session = '$session' ORDER BY id DESC");

    if ($result){
        $status = 1;
        $data = $result;
        $msg = "Record found";
    }else{
        $msg = "Record not found";
    }

}

echo json_encode(array("status" => $status, "data" => $data, "msg" => $msg));