Download Customers
You may have an occasion where you need to download some data as a CSV file. The following can be used for Cartweaver customer data. You can add more fields as needed. The same process can be used for any CW data, such as orders, email address, etc. Put this code in a file and browse to it to get the CSV download. You can link to it also:
<?php require_once("application.php");
ob_start();
$query_rsCWGetCustomer = "SELECT c.cst_ID, c.cst_FirstName, c.cst_LastName,
c.cst_City, c.cst_Zip, c.cst_Phone,
c.cst_Email FROM tbl_customers c
ORDER BY c.cst_LastName, c.cst_FirstName";
$rsCWGetCustomer = $cartweaver->db->executeQuery($query_rsCWGetCustomer, "rsCWGetCustomer");
$rsCWGetCustomer_recordCount = $cartweaver->db->recordCount;
$row_rsCWGetCustomer = $cartweaver->db->db_fetch_assoc($rsCWGetCustomer);
?>
<?php
ob_end_clean();
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: application/unknown");
header("Content-Disposition: attachment; filename=\"customers.csv\"");
header("Content-Transfer-Encoding: binary");
do {
echo($row_rsCWGetCustomer["cst_ID"] . "," . $row_rsCWGetCustomer["cst_LastName"] . "," . $row_rsCWGetCustomer["cst_FirstName"] . "," . $row_rsCWGetCustomer["cst_Email"]);
} while ($row_rsCWGetCustomer = $cartweaver->db->db_fetch_assoc($rsCWGetCustomer));
exit();
?>



Blog RSS feed












