如何在ecshop中导出用户邮箱

2016-07-07 15:01 来源:www.chinab4c.com 作者:ecshop专家

如何在ecshop中导出用户邮箱

ob_start();
/* 初始化压缩类 */
include_once('includes/cls_phpzip.php');
$zip = new PHPZip;

$where = ' where 1 ' ;
/* 获取用户邮箱 */
$sql = "select user_name,email from ".$ecs->table('users')."$where";
$res = $db->query($sql);

/* CSV 格式文件 */
$email_value = array();
$content = "username,email\n";
while ($row = $db->fetchRow($res))
{
$email_value['username'] =$row['user_name'];
$email_value['email'] =$row['email'];
$content .= implode(",", $email_value) . "\n";
}

$zip->add_file(ecs_iconv(EC_CHARSET, 'GB2312', $content),'mail_list.csv');
header("Content-Disposition: attachment; filename=mail_list.zip");
header("Content-Type: application/unknown");
ob_end_flush();
die($zip->file());

回答:
不错,.很好

路过~学习了~