mysql数据库转存到EXCEL
Header( "Content-type: application/octet-stream ");
Header( "Accept-Ranges: bytes ");
Header( "Content-type:application/vnd.ms-excel ");
Header( "Content-Disposition:attachment;filename=test.xls ");
$con = mysql_connect("localhost","root","123456");
mysql_select_db("db_test");
mysql_query(‘set names utf8‘);
$sql = "select id,FirstName,LastName,Age,Hometown,Job from user";
$result = mysql_query($sql,$con);
echo "id\tFirstName\tLastName\tAge\tHometown\tJob";
while ($rs=mysql_fetch_array($result)){
echo "\n";
echo $rs[‘id‘]."\t".$rs[‘FirstName‘]."\t".$rs[‘LastName‘]."\t".$rs[‘Age‘]."\t".$rs[‘Hometown‘]."\t".$rs[‘Job‘];
}
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。