<?php
require("php_con.php");

if(isset($_POST["query"])) {
    $search = mysqli_real_escape_string($connation, $_POST["query"]);
    $query = "SELECT cs_id, cs_name, cs_mobile FROM customer_details 
              WHERE cs_name LIKE '%".$search."%' 
              OR cs_mobile LIKE '%".$search."%' 
              LIMIT 5";
    $result = mysqli_query($connation, $query);
    
    $output = '<ul class="list-group">';
    if(mysqli_num_rows($result) > 0) {
        while($row = mysqli_fetch_array($result)) {
            $output .= '<li class="list-group-item customer_item" data-id="'.$row["cs_id"].'">'.$row["cs_name"].' ('.$row["cs_mobile"].')</li>';
        }
    } else {
        $output .= '<li class="list-group-item">Customer Not Found</li>';
    }
    $output .= '</ul>';
    echo $output;
}
?>