-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathexcel.php
More file actions
50 lines (43 loc) · 1.12 KB
/
excel.php
File metadata and controls
50 lines (43 loc) · 1.12 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
session_start();
if(isset($_SESSION['usr_id']) == "") {
header("Location: login.php");
}
include_once 'dbconnect.php';
$login_id = $_SESSION['usr_id'];
if(count($_POST) > 0 && isset($_POST["export_excel"]))
{
$output = "";
$sql = "SELECT id, expensetype, amount FROM expense WHERE users_id = ".$login_id." ORDER BY id ASC";
$result = mysqli_query($con, $sql);
if ($result && $myrow = mysqli_fetch_array($result))
{
$output .= ' <table class="table" bordered="1">
<thead>
<tr>
<th>Sr No.</th>
<th>Expense Type</th>
<th>Amount</th>
</tr>
</thead>
<tbody>';
$sr = 1;
do
{
$output .= '
<tr>
<td>'.$sr.'</td>
<td>'.$myrow['expensetype'].'</td>
<td>'.$myrow['amount'].'</td>
</tr>';
$sr++;
}
while($myrow = mysqli_fetch_array($result));
$output .= ' </tbody>
</table>';
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=download.xls");
echo $output;
}
}
?>