<?php
include("includes/db.php");

if (isset($_POST['query'])) {
    $query = $_POST['query'];
    $sql = "SELECT name FROM students WHERE name LIKE '%$query%' LIMIT 10";  // Fetch up to 10 matches
    $result = $conn->query($sql);

    if ($result->num_rows > 0) {
        while ($row = $result->fetch_assoc()) {
            // Display the fetched data in a list format
            echo '<a href="#" class="list-group-item list-group-item-action student-name-item">' . $row['name'] . '</a>';
        }
    } 
}
?>
