File: /var/www/nclive/backend/institute_get_state_list.php
<?php
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
include "config.php";
$getInstStateQuery="SELECT inst.state_id, count(inst.id) as count, s.state_name, s.image_icon, s.state_slug FROM sp_institutions as inst INNER JOIN sp_states as s ON s.state_id=inst.state_id WHERE inst.status='1' group by inst.state_id order by s.state_name";
$sqlInstState=$db->prepare($getInstStateQuery);
$sqlInstState->execute();
$instStateDataArray = array();
while($rowInstState=$sqlInstState->fetch()){
$state_id= $rowInstState['state_id'];
$inst_count= $rowInstState['count'];
$state_name = $rowInstState['state_name'];
$state_slug = $rowInstState['state_slug'];
$state_image = $rowInstState['image_icon'];
$instStateArray=array("state_id"=>$state_id, "state_name"=>$state_name, "inst_count"=>$inst_count, "state_slug"=>$state_slug, "state_image"=>$state_image);
$instStateDataArray[]=$instStateArray;
}
echo json_encode($instStateDataArray , TRUE);
?>