<?php header("content-type:application/vnd.ms-excel; charset=gbk");header("content-disposition:attachment;filename=exceltest".$_GET[id]."muzi.xls");$link=mysql_connect('localhost','root','muzi');if($link){ mysql_select_db('exceltest',$link); mysql_query("set names 'gbk'"); //echo "数据库教程连接已经成功!";}else{ echo "数据库连接失败!";}echo "编号"."/t";echo "姓名"."/t";echo "姓别"."/n"; $id = $_GET[id];$sql="select * from downtest where id ='".$id."'";$query=mysql_query($sql);while($rs=mysql_fetch_array($query)){ echo $rs[id]."/t"; echo $rs[name]."/t"; echo $rs[sex]."/n"; }
?>
转载于:https://www.cnblogs.com/J2EEPLUS/archive/2010/12/20/2487923.html