<?php
 require 'db_config/config.php';
$output='';
 if(isset($_POST['export_excel'])){
	 $sql="SELECT * FROM asset_info ";
	 $result = mysqli_query($connect,$sql);
	 if(mysqli_num_rows($result) > 0){
		 $output.='
		 <table class="table" bordered="3">
		 <tr>
		 <th>Id</th>
		 <th>User</th>
		 <th>User Status</th>
		 <th>Designation</th>
		 <th>Device</th>
		 <th>Brand</th>
		 <th>Model Number</th>
		 <th>Location</th>
		 <th>Asset Tagging</th>
		 <th>Asset Tag</th>
		 <th>Date</th>
		 </tr>
		 ';
		 while($row = mysqli_fetch_array($result))
		 {
			 $output .='
			 <tr>
			 <td>'.$row["id"].'</td>
			 <td>'.$row["user"].'</td>
			 <td>'.$row["user_status"].'</td>
			 <td>'.$row["designation"].'</td>
			 <td>'.$row["device"].'</td>
			 <td>'.$row["brand"].'</td>
			 <td>'.$row["model_num"].'</td>
			 <td>'.$row["location"].'</td>
			 <td>'.$row["asset_tagging"].'</td>
			 <td>'.$row["asset_tag"].'</td>
			 <td>'.$row["date"].'</td>			 
			 </tr>
			 ';
		 }
		 $output .='</table>';
		 header("Content-Type: application/xls");
		 header("Content-Disposition: attachment; filename=Asset_list.xls");
		 echo $output;
	 }
 }
?>