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

$status = 0;
$data = array();
$msg = "Unable to get data..!";

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

    $image_path = "https://".$_SERVER['HTTP_HOST']."/uploads/subjectimage/";

    $class = $_GET['class'];
    $session = $_GET['session'];

    $result = $db->getRows("SELECT id,subject,subject_image FROM subject_new WHERE class = '$class' /*AND session = '$session'*/ AND type = 'subject'");

    if ($result) {
        $status = 1;
        $msg = "Data found";

        foreach ($result as $item) {
            if (!empty($item['subject_image'])){
                $item['subject_image'] = $image_path.$item['subject_image'];
            }
            $data[] = $item;
        }
    }

}

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