File: /var/www/nclive/backend/institute_get_category.php
<?php
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
include "config.php";
$getInstCatQuery="SELECT inst.category_id, count(inst.id) as count, ic.category_name FROM sp_institutions as inst INNER JOIN sp_institutions_category as ic ON ic.id=inst.category_id WHERE inst.status='1' group by inst.category_id order by ic.display_order ";
$sqlInstCat=$db->prepare($getInstCatQuery);
$sqlInstCat->execute();
$instCatDataArray = array();
while($rowInstCat=$sqlInstCat->fetch()){
$category_id= $rowInstCat['category_id'];
$inst_count= $rowInstCat['count'];
$category_name = $rowInstCat['category_name'];
$instCatArray=array("category_id"=>$category_id, "category_name"=>$category_name, "inst_count"=>$inst_count);
$instCatDataArray[]=$instCatArray;
}
echo json_encode($instCatDataArray , TRUE);
?>