<?php
$mysqli = new mysqli("localhost", "apmmwfdg_apmmauser", "asgharali2007", "apmmwfdg_glakb");

if ($mysqli->connect_error) {
    die("Connection failed: " . $mysqli->connect_error);
}

if (isset($_GET['q'])) {
    $q = $mysqli->real_escape_string($_GET['q']);
    $sql = "SELECT Name, A_Id, City, Warehouse, Adress, M_Head FROM acc_heads 
            WHERE Name LIKE '%$q%'  
            ORDER BY Name ASC limit 50 ";
    $result = $mysqli->query($sql);

    if ($result->num_rows > 0) {


echo "<table border='1' cellspacing='0' cellpadding='8' 
        style='border-collapse:collapse; width:100%; font-size:20px;'>
        <tr style='background:#f2f2f2; font-size:20px; font-weight:bold;'>
            <th>Code</th>
            <th>Category</th>
            <th>Head of Accounts</th>
                    </tr>";

while ($row = $result->fetch_assoc()) {
    echo "<tr data-code='" . htmlspecialchars($row['A_Id']) . "'>
            <td>" . htmlspecialchars($row['A_Id']) . "</td>
            <td>" . htmlspecialchars($row['M_Head']) . "</td>
            <td>" . htmlspecialchars($row['Name']) . "</td>
            
          </tr>";
}










        
        echo "</table>";
    } else {
        echo "<p>No records found</p>";
    }
}
?>
