Files
User-Management-PHP-MYSQL/admin/download.php
T
2018-07-19 14:28:25 +05:30

55 lines
1.1 KiB
PHP

<?php
session_start();
//error_reporting(0);
session_regenerate_id(true);
include('includes/config.php');
if(strlen($_SESSION['alogin'])==0)
{
header("Location: index.php"); //
}
else{?>
<table border="1">
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Email</th>
<th>Gender</th>
<th>Phone</th>
<th>Designation</th>
</tr>
</thead>
<?php
$filename="Users list";
$sql = "SELECT * from Users";
$query = $dbh -> prepare($sql);
$query->execute();
$results=$query->fetchAll(PDO::FETCH_OBJ);
$cnt=1;
if($query->rowCount() > 0)
{
foreach($results as $result)
{
echo '
<tr>
<td>'.$cnt.'</td>
<td>'.$Name= $result->name.'</td>
<td>'.$Email= $result->email.'</td>
<td>'.$Gender= $result->gender.'</td>
<td>'.$Phone= $result->mobile.'</td>
<td>'.$Designation= $result->designation.'</td>
</tr>
';
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=".$filename."-report.xls");
header("Pragma: no-cache");
header("Expires: 0");
$cnt++;
}
}
?>
</table>
<?php } ?>