<?php
require 'shikanisha.kts.php';

if (isset($_GET['query'])) {
    $query = $_GET['query'];
    $stmt = $conn->prepare("SELECT * FROM tots WHERE name LIKE ?");
    $likeQuery = "%" . $query . "%";
    $stmt->bind_param("s", $likeQuery);
    $stmt->execute();
    $result = $stmt->get_result();

    $tots = array();
    while ($row = $result->fetch_assoc()) {
        $tots[] = $row;
    }

    echo json_encode($tots);
}
?>
