Tom Muck

Alpha Dog Blues Band
Home page
All articles
All Extensions | Extension News | Extension FAQs | Customer Login
Books authored or co-authored by Tom Muck
Extensions, books, and other products | Customer Login
Your current cart contents
Tom-Muck.com Blog | CMXTraneous Blog | Flash Remoting Blog
About the site

Download Customers

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();
?>

Back to Cartweaver PHP FAQ, code changes, and samples

Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
Pay me securely with your Visa, MasterCard, Discover, or American Express card through PayPal!
About | Privacy Policy | Contact | License Agreement | ©2002-2025 Tom Muck | Dreamweaver Extensions