PHP导出mysql数据到txt并自动下载

at 4年前  ca 记录笔记  pv 1874  by authorhu  

$now_date = date("Y-m-j H:i:s"); 
$title = "导出日期:$now_date"; 
  while($row=$empire->fetch($sql))
  { 
$content.= '卡号:' . $row['card_no'] . ' -- 密码:' . $row['password'] . ' -- ' . $row['carddate'] . "天" . "\r\n";
  }
Header("Content-type:application/octet-stream");
Header("Accept-Ranges:bytes");
header("Content-Disposition:attachment;filename=$title.txt");
header("Expires:0");
header("Cache-Control:must-revalidate,post-check=0,pre-check=0 ");
header("Pragma:public");
echo $content;


版权声明

本文仅代表作者观点,未经许可,不得转载。

分享:

支付宝

微信