<?php
include ('../config.php');
if(!empty($_POST["cityID"])){ 
    $query = "SELECT * FROM locations WHERE cityID = ".$_POST['cityID']." ORDER BY location ASC"; 
    $result = $conn->query($query); 
    if($result->num_rows > 0){ 
        echo '<option value="">Select Ofice/Site Location</option>'; 
        while($rowcat = $result->fetch_assoc()){  
            echo '<option value="'.$rowcat['location'].'">'.$rowcat['location'].'</option>'; 
        }
    }else{	echo '<option value="">Ofice/Site not available</option>';	} 
}
	/* ================================================ */	
$location_name = $_REQUEST['location_name'];
	$sql = "SELECT id, latitude, longitude, bh_empid FROM locations WHERE location = '$location_name'";
	$result = $conn->query($sql);
	if ($result->num_rows > 0) {
		while($row = $result->fetch_assoc()) {
			$id = $row["id"];
			$latitude = $row["latitude"];
			$longitude = $row["longitude"];
			$bh_empid = $row["bh_empid"];
			$result = array("$id","$latitude","$longitude","$bh_empid");
			$myJSON = json_encode($result);
			echo $myJSON;			die;
		}
	}
	/* ================================================ */	
if(!empty($_POST["cityID_proj"])){ 
    $query = "SELECT * FROM porj_locations WHERE cityID_proj = ".$_POST['cityID_proj']." ORDER BY Location ASC"; 
    $result = $connpe->query($query); 
    if($result->num_rows > 0){ 
        echo '<option value="">-Select Location-</option>'; 
        while($rowcat = $result->fetch_assoc()){  
            echo '<option value="'.$rowcat['Location'].'">'.$rowcat['Location'].'</option>'; 
        }
    }else{	echo '<option value="">Location not available</option>';	} 
}

	/* ================================================ */
	
