home/abhiramc/public_html/acts.service/fetch_locations.php 0000644 00000001400 15021151164 0020001 0 ustar 00 getConnection();
if (isset($_GET['branch_id'])) {
$branch_id = $_GET['branch_id'];
// Query to fetch locations based on the branch ID
$query = "SELECT lo_id, lo_name FROM acts_location WHERE branch_id = :branch_id";
$stmt = $db->prepare($query);
$stmt->bindParam(':branch_id', $branch_id, PDO::PARAM_INT);
$stmt->execute();
// Prepare the result as an array
$locations = [];
if ($stmt->rowCount() > 0) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$locations[] = $row; // Add each locations to the array
}
}
// Return the JSON response
echo json_encode($locations);
}
?>