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

if (isset($_POST['symbol_no'])) {
    $symbol_no = $_POST['symbol_no'];

    // Query to fetch both student_id and name
    $query = "SELECT student_id, name FROM students WHERE symbol_no = ?";
    $stmt = $conn->prepare($query);
    $stmt->bind_param('s', $symbol_no);
    $stmt->execute();
    $stmt->bind_result($student_id, $name);
    $stmt->fetch();

    if ($name) {
        // Return both student_id and name as JSON
        echo json_encode(['student_id' => $student_id, 'name' => $name]);
    } else {
        echo json_encode(['error' => 'Student not found']); // Error response if no student is found
    }

    $stmt->close();
}
?>
