php 匯出csv檔案程式_PHP教程

來源:互聯網
上載者:User
php 匯出csv檔案程式


$Date = date("Y-m-d");
$Filename = $Date.'_'.date("h_i_s").".csv";
$Table = isset($_GET['tid'])?$_GET['tid']:'';
$Auto = isset($_POST['d'])?$_POST['d']:'';
if( is_numeric($Auto ) ){
$Table =$Auto;
}
$a = "使用者名稱,真實姓名,連絡方式,聯絡QQ,聯絡地址,郵箱地址 rn";
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=".$Filename);
$Sql = "Select * from gx_member";
$Result = mysql_query($Sql) or die(mysql_error());
while($rs = mysql_fetch_array($Result) ){
if(get_days($rs['m_time'])<= $Table ){
$a.=$rs['m_name'].','. $rs['m_realname'].",". $rs['m_tel'].",". $rs['m_qq'].",";
$a.="".$rs['m_address'].",". $rs['m_mail']." rn ";
}
}
echo $a;

function get_days($base){

$Date_1=date("Y-m-d");//格式也可以是:$Date_1="2003-6-25 23:29:14";

$Date_2=substr($base,0,10);

$Date_List_a1=explode("-",$Date_1);

$Date_List_a2=explode("-",$Date_2);
//print_r($Date_List_a2);

$d1=mktime(0,0,0,$Date_List_a1[1],$Date_List_a1[2],$Date_List_a1[0]);

$d2=mktime(0,0,0,$Date_List_a2[1],$Date_List_a2[2],$Date_List_a2[0]);
//echo round(($d1-$d2)/3600/24),'
';
return round(($d1-$d2)/3600/24);


}
?>
本站原創轉載請註明 www.111cn.cn/phper/php.html

http://www.bkjia.com/PHPjc/630429.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630429.htmlTechArticlephp 匯出csv檔案程式 ?php $Date = date(Y-m-d); $Filename = $Date.'_'.date(h_i_s)..csv; $Table = isset($_GET['tid'])?$_GET['tid']:''; $Auto = isset($_POST['d'])?$_POST['d']:'';...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.