Home > Backend Development > PHP Tutorial > PHP export csv file program_PHP tutorial

PHP export csv file program_PHP tutorial

WBOY
Release: 2016-07-13 17:07:17
Original
1072 people have browsed it

php csv file export 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 = "Username, 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 ){
$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);

$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);


}
?>
Please indicate www.111cn.cn/phper/php.html

for original reprints on this site

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630429.htmlTechArticlephp 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']:'';...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template