File: /var/www/nclive/backend/get_all_state_data.php
<?php
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
include "config.php";
$query="Select DISTINCT(state_id) as s from sp_exam where state_id!='' ";
$sql=$db->prepare($query);
$sql->execute();
while($row=$sql->fetch()){
$state_id=$row['s'];
$qery2="select exam_name from sp_exam where state_id='$state_id'";
$sql2=$db->prepare($query2);
$sql2->execute();
while($row2 = $sql2->fetch()){
$exam= $row['exam_name'];
$array = array("name"=>$exam);
$mainarray[]=$array;
}
$array2=array("id"=>$state_id,"exam"=>$mainarray);
$main[]=$array2;
}
echo json_encode($main , TRUE);
?>