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

if (isset($_REQUEST['session']) && isset($_REQUEST['uid']) && isset($_REQUEST['class'])) {
    $session = $_REQUEST['session'];
    $uid = $_REQUEST['uid'];
    $class = $_REQUEST['class'];

    $result = $db->getRows("select id,uid,content,type,session,timestamp,DATE(timestamp) as date, TIME(timestamp) as time from 
                tbl_notification where session='$session' and (uid='$uid' or (uid = 0 AND (class = '$class' or class = ''))) order by id desc");

    echo json_encode(array('status' => 1, "data" => $result, 'msg' => 'query executed'));

} else {

    echo json_encode(array('status' => 0, "data" => array(), 'msg' => 'session and user id needed..!'));

}