<?php

require("includes/check_auth_user.php");
require("includes/dbconnect.php");
include ('includes/function.php');


$zdb = $_SESSION["zdbyear_" . $dbname];
mysqli_select_db($conn, $zdb);

$searchTerm = $_REQUEST["ssearch"];
$searchcond = "";
if (!empty($searchTerm)) {
    $searchcond = "and `broker` LIKE N'%$searchTerm%'";
}

mysqli_query($conn, "Create temporary table `agntmp` SELECT `broker` FROM `visamain` WHERE broker != '' 
                                                   UNION all
                                                   SELECT name as broker from accmast where grpcode='040'") or die(mysqli_error($conn));

$getbroker = mysqli_query($conn, "Select broker  from agntmp where broker != '' $searchcond group by broker order by broker ") or die(mysqli_error($conn));
while ($r = mysqli_fetch_array($getbroker)) {

    $broker = $r['broker'];

    echo "<tr class=''>";
    echo "<td class='tdbroker'>$broker</td>";
    echo "</tr>";
}
?>