File: /var/www/nclive/backend/state_home_data.php
<?php
header("Access-Control-Allow-Origin: *");
header('Content-Type: application/json');
include "config.php";
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$json = file_get_contents('php://input');
$data = json_decode($json);
$slug = $data->state;
$getStateDataQuery = "select state_name, state_slug, state_code, state_img, state_description, state_adv, latitude, longitude from sp_states where state_slug='$slug' ";
$getStateData = $db->prepare($getStateDataQuery);
$getStateData->execute();
$data = array();
while($exRes=$getStateData->fetch()){
if($exRes['state_img']==''){
$stateImage = "state_common_banner.png";
} else {
$stateImage = $exRes['state_img'];
}
$nestedData = array();
$nestedData["state_name"] = $exRes['state_name'];
$nestedData["state_slug"] = $exRes['state_slug'];
$nestedData["state_code"] = $exRes['state_code'];
$nestedData["state_img"] = $stateImage;
$nestedData["state_description"] = $exRes['state_description'];
$nestedData["state_adv"] = $exRes['state_adv'];
$nestedData["latitude"] = $exRes['latitude'];
$nestedData["longitude"] = $exRes['longitude'];
$data[] = $nestedData;
}
$json_data = array($data);
echo json_encode($json_data);
?>