<?php

//Database connection
require('shikanisha.kts.php');

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

// Fetch branch data from the database
$sql = "SELECT branch_id, branch_name FROM branch";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // Output data as JSON
    $branches = array();
    while ($row = $result->fetch_assoc()) {
        $branches[] = $row;
    }
    echo json_encode($branches);
} else {
    // No branches found
    echo json_encode(array());
}

// Close the connection
$conn->close();

?>
