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 ']: ';