-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExport_Excel.php
55 lines (49 loc) · 1.86 KB
/
Export_Excel.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
//Connect to database
require'connectDB.php';
$output = '';
if(isset($_POST["To_Excel"])){
if ( empty($_POST['date_sel'])) {
$Log_date = date("Y-m-d");
}
else if ( !empty($_POST['date_sel'])) {
$Log_date = $_POST['date_sel'];
}
$sql = "SELECT * FROM users_logs WHERE checkindate='$Log_date' ORDER BY id DESC";
$result = mysqli_query($conn, $sql);
if($result->num_rows > 0){
$output .= '
<table class="table" bordered="1">
<TR>
<TH>ID</TH>
<TH>Name</TH>
<TH>Serial Number</TH>
<TH>Fingerprint ID</TH>
<TH>Date log</TH>
<TH>Time In</TH>
<TH>Time Out</TH>
</TR>';
while($row=$result->fetch_assoc()) {
$output .= '
<TR>
<TD> '.$row['id'].'</TD>
<TD> '.$row['username'].'</TD>
<TD> '.$row['serialnumber'].'</TD>
<TD> '.$row['fingerprint_id'].'</TD>
<TD> '.$row['checkindate'].'</TD>
<TD> '.$row['timein'].'</TD>
<TD> '.$row['timeout'].'</TD>
</TR>';
}
$output .= '</table>';
header('Content-Type: application/xls');
header('Content-Disposition: attachment; filename=User_Log'.$Log_date.'.xls');
echo $output;
exit();
}
else{
header( "location: UsersLog.php" );
exit();
}
}
?>