HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/barbeatleanalyti/public_html/api.beatleanalytics.com/corporate/get_state.php
<?php
/*
 * Following code will get single department details
 * A industry is identified by dept_id
 */
 
// array for JSON response
$response = array();
 
// include db connect class
require_once 'db_connect.php';
 
// connecting to db
$db = new DB_CONNECT();
 
if (isset($_GET["state_id"])) {
    $stateid = $_GET['state_id'];
	
	$result = mysql_query("SELECT * FROM cities WHERE state_id LIKE '$stateid' ")or die(mysql_error());
	 if (!empty($result)) {
        // check for empty result
        if (mysql_num_rows($result) > 0) {
 
			 $response["cityDetail"] = array();
			  while ($row = mysql_fetch_array($result)) {
				  
				$cityDetail = array();
				$cityDetail["id"] = $row["id"];
				$cityDetail["name"] = $row["name"];
				$cityDetail["stateId"] = $row["state_id"];
			
				// push single product into final response array
				array_push($response["cityDetail"], $cityDetail);
			}
          
            // success
            $response["success"] = 1;

            // echoing JSON response
            echo json_encode($response);
        } else {
            // no product found
            $response["success"] = 0;
            $response["message"] = "No city found";
 
            // echo no users JSON
            echo json_encode($response);
        }
    }  else {
        // no industry found
        $response["success"] = 0;
        $response["message"] = "No city found.";
 
        // echo no users JSON
        echo json_encode($response);
    }
}elseif(isset($_GET["country_id"])){
     $countryid = $_GET['country_id']; //india code = 101
    $result = mysql_query("SELECT * FROM states where country_id = ".$countryid." ")or die(mysql_error());
	if (!empty($result)) {
        // check for empty result
		if (mysql_num_rows($result) > 0) {
 
			 $response["statesDetail"] = array();
			  while ($row = mysql_fetch_array($result)) {
				  
				$statesDetail = array();
				$statesDetail["id"] = $row["id"];
				$statesDetail["name"] = $row["name"];
				$statesDetail["countryId"] = $row["country_id"];
			
				// push single product into final response array
				array_push($response["statesDetail"], $statesDetail);
			}
          
            // success
            $response["success"] = 1;

            // echoing JSON response
            echo json_encode($response);
        } else {
            // no product found
            $response["success"] = 0;
            $response["message"] = "No state found";
 
            // echo no users JSON
            echo json_encode($response);
        }
       
    }  else {
        // no industry found
        $response["success"] = 0;
        $response["message"] = "No state found.";
 
        // echo no users JSON
        echo json_encode($response);
    }
}else{
	
	 $result = mysql_query("SELECT * FROM countries ")or die(mysql_error());
	if (!empty($result)) {
        // check for empty result
		if (mysql_num_rows($result) > 0) {
 
			 $response["countryDetail"] = array();
			  while ($row = mysql_fetch_array($result)) {
				  
				$countryDetail = array();
				$countryDetail["id"] = $row["id"];
				$countryDetail["sortname"] = $row["sortname"];
				$countryDetail["name"] = $row["name"];
				$countryDetail["phonecode"] = $row["phonecode"];
			
				// push single product into final response array
				array_push($response["countryDetail"], $countryDetail);
			}
          
            // success
            $response["success"] = 1;

            // echoing JSON response
            echo json_encode($response);
        } else {
            // no product found
            $response["success"] = 0;
            $response["message"] = "No state found";
 
            // echo no users JSON
            echo json_encode($response);
        }
       
    }  else {
        // no industry found
        $response["success"] = 0;
        $response["message"] = "No state found.";
 
        // echo no users JSON
        echo json_encode($response);
    }
	
}
?>