forked from NYCPlanning/edm-metadata-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpcsv_dict.php
More file actions
20 lines (20 loc) · 802 Bytes
/
expcsv_dict.php
File metadata and controls
20 lines (20 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
include 'config.php';
$sde_underscore = $_GET['sde_underscore'];
// Connect to the Database
if (isset($_POST["Export"])) {
//get records from database
header('Content-Type: text/csv;');
header('Content-Disposition: attachment; filename='.$sde_underscore .'.csv'); //this dowloads the csv file with the given name
//opening the csv file to be downloaded
$fp = fopen("php://output", "w");
fputcsv($fp, array('order', 'field_name', 'longform_name', 'description', 'geocoded', 'required', 'data_type', 'expected_allowed_values', 'last_modified_date', 'no_longer_in_use', 'notes'));
$q = 'select * from '.$sde_underscore ;
$query = pg_query($q);
//fetching values to write into the csv file
while($row = pg_fetch_assoc($query)) {
fputcsv($fp, $row);
}
fclose($fp);
}
?>