<?php
if(isset($_POST["csv"]))
{
 require 'db_config/config.php';
 
 header('Content-Type: text/csv; charset=utf-8');
 header('Content-Disposition: attachment; filename=data.csv');
 $output = fopen("php://output", "w");
 fputcsv($output, array('ID', 'User', 'User Status', 'Designation', 'Device', 
 'Brand', 'Model Number', 'Location', 'Asset Tagging', 'Asset Tag', 'Date' ));
$query = "SElECT * from asset_info ORDER BY id DESC";
$result = mysqli_query($connect, $query);
 while($row = mysqli_fetch_assoc($result))
 {
	 fputcsv($output, $row);
 }
 fclose($output);
 }
?>