-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexcel test.php
38 lines (36 loc) · 926 Bytes
/
excel test.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
<?php
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=XL_".date("m-d-Y").".xls");
header("Pragma: no-cache");
header("Expires: 0");
require 'config.php';
/*
* Logged in page initialization
*/
include($config['root_dir'] . 'includes/bootstrap.inc');
connect();
$select = "SELECT * FROM map";
$export = mysql_query($select);
$count = mysql_num_fields($export);
for ($i = 0; $i < $count; $i++) {
$header .= mysql_field_name($export, $i)."\t";
}
while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) OR ($value == "")) {
$value = "\t";
} else {
$value = str_replace('"', '""', $value);
$value = '"' . $value . '"' . "\t";
}
$line .= $value;
}
$data .= trim($line)."\n";
}
$data = str_replace("\r", "", $data);
if ($data == "") {
$data = "\n(0) Records Found!\n";
}
print "$header\n$data";
?>