<?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 cate_name FROM category";
$result = $conn->query($sql);

if ($result === false) {
    // Query execution failed
    die("Error executing the query: " . $conn->error);
}

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

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

?>
