<?php
include "../config.php"; // Include your DB connection file

if (isset($_POST['lr_no'])) {
    $lr_nos = $_POST['lr_no'];
    if (!is_array($lr_nos)) {
        $lr_nos = array($lr_nos);
    }
    $lr_nos = implode("','", array_map('mysqli_real_escape_string', $lr_nos)); // Sanitize and convert to string

    $query = "SELECT lr_no FROM lr_mst WHERE lr_no IN ('$lr_nos')";
    $result = mysqli_query($conn, $query);

    if (mysqli_num_rows($result) > 0) {
        $lr_no_list = '';
        while ($row = mysqli_fetch_assoc($result)) {
            $lr_no = $row['lr_no'];
            $lr_no_list .= $lr_no . ', '; // Append LR NOs with a comma
        }
        echo rtrim($lr_no_list, ', '); // Remove trailing comma and space
    } else {
        echo ''; // Return empty if no LR NOs are found
    }
}
?>
