<?php session_start();
include("db/db.php");
//include 'db_connect.php'; // your db connection file

if (isset($_POST["query"])) {
    $query = "SELECT id, hotel_name 
              FROM hotels 
              WHERE hotel_name LIKE '%" . $_POST["query"] . "%' 
              AND val=1 
              ORDER BY hotel_name ASC 
              LIMIT 10";

    $result = mysqli_query($db, $query);

    $output = '<ul class="list-group">';
    if (mysqli_num_rows($result) > 0) {
        while ($row = mysqli_fetch_array($result)) {
            // id එක data-id attribute එකේ දාන්න
            $output .= '<li class="list-group-item hotel_item" data-id="' . $row["id"] . '">' . $row["hotel_name"] . '</li>';
        }
    } else {
        $output .= '<li class="list-group-item disabled">No hotels found</li>';
    }
    $output .= '</ul>';
    echo $output;
}
