<?php 
include("../db.php");

header('Content-Type: application/json');

  $class = $_POST['class'];

    $status = 0;

    $subjectArray = array();
    
    $array = array();

	$allSubject = $db->getRows("select * from subject_new where class='$class' and type='subject' ");
    if(count($allSubject) > 1){
        $status = 1;

    	foreach($allSubject as $subject){
                array_push($subjectArray,["id"=>"$subject[id]","name"=>"$subject[subject]","image"=>"$_SERVER[HTTP_HOST]/uploads/subjectimage/$subject[subject_image]" ]);
    	}

    }
 
 $array['status'] = $status;
 $array['subjects'] = $subjectArray;
 
 echo json_encode($array);
?>