PHP Export CSV file program _php Tutorial

Source: Internet
Author: User
PHP Export CSV file program


$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, e-mail 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) {
$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");//The format can also be: $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);

$d 1=mktime (0,0,0, $Date _list_a1[1], $Date _list_a1[2], $Date _list_a1[0]);

$d 2=mktime (0,0,0, $Date _list_a2[1], $Date _list_a2[2], $Date _list_a2[0]);
Echo Round (($d 1-$d 2)/3600/24), '
';
Return round (($d 1-$d 2)/3600/24);


}
?>
This site original reprint please specify www.111cn.cn/phper/php.html

http://www.bkjia.com/PHPjc/630429.html www.bkjia.com true http://www.bkjia.com/PHPjc/630429.html techarticle PHP export CSV file program? 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 ']: ';

  • 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.