批量导出用户信息

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

批量导出用户信息,只导出一行数据,不知道是怎么回事,已下是我的代码。

<?php
define('IN_ECS', true);
include ('includes/init.php');
$filename='excel_export';
header("Content-type: application/vnd.ms-excel; charset=utf-8");
header("Content-Disposition: attachment; filename=$filename.xls");
$sql="SELECT `user_id` , `email` , `user_name` , `office_phone` , `home_phone` , `mobile_phone`
FROM `ecs_users`
";

$res=$db->getAll($sql);

$data1.='用户编号'."\t";
$data1.='用户邮箱'."\t";
$data1.='用户名称'."\t";
$data1.='用户办公电话'."\t";
$data1.='用户家电话'."\t";
$data1.='用户手机'."\t\n";

foreach ($res as $keys=>$vars)
{
$res1[$key]['user_id']=$vars['user_id'];
$res1[$key]['email']=$vars['email'];
$res1[$key]['user_name']=$vars['user_name'];
$res1[$key]['office_phone']=$vars['office_phone'];
$res1[$key]['home_phone']=$vars['home_phone'];
$res1[$key]['mobile_phone']=$vars['mobile_phone'];
unset ($res[$keys]);

}

foreach ($res1 as $key =>$var)
{
$data.=$var['user_id']."\t";
$data.=$var['email']."\t";
$data.=$var['user_name']."\t";
$data.=$var['office_phone']."\t";
$data.=$var['home_phone']."\t";
$data.=$var['mobile_phone']."\t";

$data.="\t\n";
}
if (EC_CHARSET != 'gbk')
{
echo $data1.ecs_iconv(EC_CHARSET, 'gbk', $data) . "\t";
}
else
{
echo $data1.$data. "\t";
}
?>

回答:
不错。好想法。支持一个

那麻烦修改一下啊。。。。没出来呢

呵呵,麻烦修改一下啊,