Php export mysql to cvsexecel table php export mysql to cvs execel table
Script ec (2); script
Include_once (dirname (_ FILE _). '.../../Inc/Conn. php ');
Include_once (dirname (_ FILE _). '.../../photo/Inc/function. php ');
$ Date = date ("Y-m-d ");
$ Filename = $ Date. '_'. date ("h_ I _s"). ". csv ";
$ A = "account, email, gender, baby birth date, province, real name, zip code, mobile phone number, address rn ";
Header ("Content-type: application/vnd. ms-excel ");
Header ("Content-Disposition: filename =". $ Filename );
$ SQL = "Select * from oy_use ";
$ Result = mysql_query ($ SQL) or die (mysql_error ());
While ($ rs = mysql_fetch_array ($ Result )){
// If (get_days ($ rs ['m _ time']) <= $ Table ){
$. = $ Rs ['user _ name']. ','. $ rs ['user _ mail']. ",". ($ rs ['user _ Baby_Sex ']? 'Male': 'female '). ",". $ rs ['user _ Baby_Birth']. ",";
$. = "". $ Rs ['sheng']. ",". $ rs ['user _ rname']. ",". $ rs ['user _ zip']. ",". $ rs ['user _ hand']. ",". $ rs ['user _ address']. "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 );
}
?>