0
点赞
收藏
分享

微信扫一扫

从mysql导出到excel 格式为.csv

49路末班车 2022-07-27 阅读 90

<?php
include_once("dbconini.php");
$EXCEL_OUT="姓,名,年龄,生日\n";
$query="select * from $test_data";
$result=mysql_query($query);
while($ROW=mysql_fetch_array($result))
{
$xing=$ROW['xing'];
$ming=$ROW["ming"];
$age=$ROW["age"];
$birthday=$ROW["birthday"];
$EXCEL_OUT.="$xing,$ming,$age,$birthday\n";
}
header("Expires: 0");
header("Cache-control: private");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Description: File Transfer");
header("Content-Type: application/vnd.ms-excel");
header("Content-disposition: attachment; filename=file_name.csv");echo $EXCEL_OUT;
mysql_close($con);?>

举报

相关推荐

0 条评论