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

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

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

    $folder_path = '/media/photo/';

    $idno = $_GET['idno'];

    $stu_sib   = $db->getval("select sibling from student where idno = '$idno' ");
    $csvString = "$stu_sib";
    $options   = explode(",", $csvString);
    $options   = array_filter($options);

    if(count($options) > 0)
    {
        foreach($options as $student_id) {
            $res = $db->getRow("select name,mobile,photo,admissionno,class,section from student where idno = '$student_id' ");
            if ($res && count($res) > 1){
                if (!empty($res['photo'])){
                    $res['photo'] = $folder_path.$res['photo'];
                }else{
                    $res['photo'] = "";
                }
                $data[] = $res;
            }
        }
    }

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

}

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