if(isset($_POST["export_excel"]))
{ $sql = "SELECT tract1,CardNum,tract2,tract3 FROM exceldata a LEFT JOIN tblcardnum b on a.EXID =b.EXID ";
$result = mysqli_query($connect, $sql);
if(mysqli_num_rows($result) > 0)
{
$output .= '
<table class="table" bordered="1">
<tr>
<th>Id</th>
<th>First Name</th>
<th>Last Name</th>
</tr>
';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["tract1"].'</td>
<td>'.$row["CardNum"].'</td>
<td>'.$row["tract2"].'</td>
</tr>
';
}
$output .= '</table>';
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=download.xls");
echo $output;
}
}