-
Notifications
You must be signed in to change notification settings - Fork 0
/
cust-export.php
29 lines (21 loc) · 1.14 KB
/
cust-export.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
<?php
/*
EXPORT.PHP
Export all data from 'customers' table
*/
// connect to the database
include('linkupdb.php');
//display clean utf8 data
require 'php-excel.class.php';
// get results from database
$result = mysql_query("SELECT customerNumber, customerName, contactLastName, contactFirstName, phone, addressLine1,addressLine2,city,state,postalCode,country, salesRepEmployeeNumber, creditLimit FROM customers")
or die(mysql_error());
$data[] = array('customerNumber', 'customerName','contactLastName','contactFirstName','phone','addressLine1','addressLine2','city','state','postalCode','country','salesRepEmployeeNumber','creditLimit');
while($row = mysql_fetch_array($result)){
$data[] = array($row['customerNumber'],$row['customerName'],$row['contactLastName'],$row['contactFirstName'],$row['phone'],$row['addressLine1'],$row['addressLine2'],$row['city'],$row['postalCode'],$row['country'],$row['salesRepEmployeeNumber'],$row['creditLimit']);
}
// generate file (constructor parameters are optional)
$xls = new Excel_XML('UTF-8', false, 'Customers');
$xls->addArray($data);
$xls->generateXML('Exports_CustomersReport');
?>