empid.php
657 Bytes
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
<?php
$link = mysqli_connect("10.4.105.141", "root", "yb9738z", "fullerton");
if(!link)
{
die("Connection Failed!".mysqli_connect_error());
}
$query = "SELECT id,lan,client FROM records";
$sql = mysqli_query($link, $query);
$sqlResult = mysqli_fetch_all($sql,MYSQLI_ASSOC);
$reportArr = array();
foreach($sqlResult as $res)
{
$reportArr[] = $res;
}
header('Content-Type: application/csv');
header('Content-Disposition: attachment; filename="record_empid_'.date('d_m').'.csv";');
$headers = ['id','lan','client'];
$f = fopen('php://output','w');
fputcsv($f, $headers);
foreach($reportArr as $arr)
{
fputcsv($f, $arr);
}
mysqli_close($link);
?>