forked from MuktaGhosh/Automated-Food-Ordering-System
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexport.php
35 lines (33 loc) · 904 Bytes
/
export.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
//export.php
$connect = mysqli_connect("localhost", "root", "", "db_shop");
$output = '';
if(isset($_POST["export"]))
{
$query = "SELECT * FROM tbl_order ORDER BY date DESC";
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
$output .= '
<table class="table" bordered="1">
<tr>
<th>Name</th>
<th>Quantity</th>
</tr>
';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["productName"].'</td>
<td>'.$row["quantity"].'</td>
</tr>
';
}
$output .= '</table>';
header('Content-Type: application/xls');
header('Content-Disposition: attachment; filename=download.xls');
echo $output;
}
}
?>