<?php
// Database connection
require('shikanisha.kts.php'); // Adjust the path accordingly

// Fetch shelf data from the database
$sql = "SELECT `shelf_id`, `shelfname` FROM `shelf`";
$result = $conn->query($sql);

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

$shelfData = array();
while ($row = $result->fetch_assoc()) {
    $shelfData[] = array(
        'id'   => $row['shelfname'],
        'text' => $row['shelfname']
    );
}

// Output data as JSON
header('Content-Type: application/json');
echo json_encode($shelfData);

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