Php export csv file project_php tutorial

Source: Internet
Author: User
Php exports the csv file program. How does php export csv files? Php1_datedate(y-m-d1_1_1_filename1_date._.date(h_ I _s1_.csv; $ Tableisset ($ _ GET [tid])? $ _ GET [tid]:; $ Autoisset ($ _ POST [d])? $ _ POST [d]:; php exports csv files


$ 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 = "user name, real name, contact information, contact QQ, contact address, email address 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 ){
$. = $ Rs ['m _ name']. ','. $ rs ['m _ realname']. ",". $ rs ['m _ tel ']. ",". $ rs ['m _ QQ']. ",";
$ A. = "". $ rs ['m _ address']. ",". $ rs ['m _ mail']. "rn ";
}
}
Echo $;

Function get_days ($ base ){

$ Date_1 = date ("Y-m-d"); // The format can also be: $ Date_1 = "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 );


}
?>
For original site reprinted, please indicate www.111cn.cn/phper/php.html

Http://www.bkjia.com/PHPjc/630429.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/630429.htmlTechArticlephp export csv file program? Php $ Date = date (Y-m-d); $ Filename = delimiter; $ Table = isset ($ _ GET ['tid'])? $ _ GET ['tid']: ''; $ Auto = isset ($ _ POST ['D'])? $ _ POST ['D']: '';...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.