-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproducts_export.php
More file actions
19 lines (18 loc) · 904 Bytes
/
Copy pathproducts_export.php
File metadata and controls
19 lines (18 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
require_once 'includes/auth.php';
require_login();
require_once 'includes/db.php';
header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename=products_export.csv');
$output = fopen('php://output', 'w');
fputcsv($output, [
'product_code','product_name','product_type','primary_type','shape','device','accuracy','frequency',
'primary_value','secondary_value','extension','isolation_level','cable_length','cable_type',
'connection_type','burden','additional_info','stock'
]);
$stmt = $pdo->query("SELECT product_code, product_name, product_type, primary_type, shape, device, accuracy, frequency, primary_value, secondary_value, extension, isolation_level, cable_length, cable_type, connection_type, burden, additional_info, stock FROM products");
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
fputcsv($output, $row);
}
fclose($output);
exit;