<?php  session_start(); error_reporting(0); 
if(isset($_SESSION['j_admin'])){ 
require_once("../j_conn/url.php");
require_once("../j_conn/dbc.php");
require_once("../j_incs/functions.php");
//The header for .xlsx files is Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
//The header for .xls files is Content-type: application/vnd.ms-excel
$data ="<table><tr><td>Gender</td><td>Name</td><td>Account Type</td><td>Phone Number</td><td>Email Address</td><td>Country</td><td>Address</td></tr>";
$sql255x="SELECT * from j_users WHERE 
j_deleted < 1 AND j_status < 1"; //  
$result255x = runSQL($sql255x);
while($row = mysqli_fetch_array($result255x)){
$data .= "
<tr><td>".$row['j_gender']."</td><td>".$row['j_firstname']." ".$row['j_lastname']."</td><td>".$row['j_account_type']."</td><td>".$row['j_phone']."</td><td> ".$row['j_email']."</td><td>".$row['j_country']."</td><td>".$row['j_address']."</td></tr>
";
}
$data .="</table>";
$time = time();
$filename ="Users-Data-$time.xls";
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=$filename");
echo $data;
exit;
}
?>