Skip to content

Instantly share code, notes, and snippets.

@oimtrust
Created October 25, 2017 03:29
Show Gist options
  • Save oimtrust/f15e22dbd3b61414725573ec2b9ce743 to your computer and use it in GitHub Desktop.
Save oimtrust/f15e22dbd3b61414725573ec2b9ce743 to your computer and use it in GitHub Desktop.
<?php
/**
* Created by PhpStorm.
* User: oimtrust
* Date: 31/08/17
* Time: 13:07
*/
//this function for sending raw excel data
header("Content-type: application/vnd-ms-excel");
$now = date('Y-m-d');
//definition name of file
header("Content-Disposition: attachment; filename=data-surveyor-'{$now}'.xls");
?>
<table border="1">
<tr>
<th>No.</th>
<th>NPM</th>
<th>Nama</th>
<th>Prodi</th>
<th>Tahun Lulus</th>
<th>No. Telepon</th>
<th>Email</th>
</tr>
<?php
$query = $connect->execute("SELECT * FROM tbl_questionnaire ORDER BY id_questionnaire ASC");
$no = 1;
while ($data = $query->fetch_object()) {
?>
<tr>
<td><?php echo $no;?></td>
<td><?php echo $data->npm;?></td>
<td><?php echo $data->name;?></td>
<td><?php echo $data->prody;?></td>
<td><?php echo $data->graduation_year;?></td>
<td><?php echo $data->phone;?></td>
<td><?php echo $data->email;?></td>
</tr>
<?php
$no++;
}
?>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment