/**
* 导出一键登录日志
*/
function export_excel($start=”,$end=”,$status=100){
ini_set(‘max_execution_time’, ‘600’);
if($status < 100)
{
$cond = ‘ and status=’.$status;
}
$sql = “select * from one_key_login_infos where mtime>='{$start}’ and mtime <='{$end}’ $cond order by id desc “;
// var_dump($sql);
$datas = $this->OneKeyLoginInfo->query($sql);
foreach($datas as $k=>$item)
{
if(!$item[‘OneKeyLoginInfo’][‘address’])
{
// $datas[$k][‘OneKeyLoginInfo’][‘address’] = $this->get_from($item[‘OneKeyLoginInfo’][‘phone’]);
}
}
// var_dump($datas);die();
// var_dump($datas);
// return;
header(“Content-type:application/vnd.ms-excel”);
header(“Content-Disposition:attachment;filename=” . “一键登录日志.csv”);
echo iconv(“UTF-8″,”GBK”,”\”用户ID\”,\”电话\”,\”地址\”,\”版本\”,\”运营商\”,\”状态\”,\”时间\”,\r\n”);
//print_r($total_statistics);
foreach($datas as $data){
iconv(“UTF-8″,”GBK”,$data);
echo(“\”” . $data[‘one_key_login_infos’][‘member_id’] . “\”,”);
echo(“\”” . $data[‘one_key_login_infos’][‘phone’] . “\”,”);
echo(“\”” . iconv(“UTF-8″,”GBK”,$data[‘one_key_login_infos’][‘address’]) . “\”,”);
echo(“\”” . iconv(“UTF-8″,”GBK”,$data[‘one_key_login_infos’][‘version’]) . “\”,”);
echo(“\”” . iconv(“UTF-8″,”GBK”,$data[‘one_key_login_infos’][‘operator’]) . “\”,”);
if($data[‘one_key_login_infos’][‘status’] == 1) {
echo(“\”” . iconv(“UTF-8″,”GBK”,”成功”) . “\”,”);
} else {
echo(“\”” . iconv(“UTF-8″,”GBK”,”失败”) . “\”,”);
}
echo(“\”” . $data[‘one_key_login_infos’][‘mtime’] . “\”,\n”);
}
exit();
}
小杰博客 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP 导出csv模板