首页 >后端开发 >php教程 > PHP怎么将查询结束导出Excel

PHP怎么将查询结束导出Excel

WBOY
WBOY原创
2016-06-13 12:41:58944浏览

PHP如何将查询结束导出Excel

<form action="user.php" method="POST"><br />
	用户编号:<input type="text" name="u_num" size="12" value="<?php echo $_POST['u_num']; ?>" />  <br />
	用户名:<input type="text" name="u_name" size="20" value="<?php echo $_POST['u_name']; ?>" />  <br />
	<input type="submit" name="sub" value=" 查询 " />      <br />
	<input type="button" value="导出Excel" /><br />
</form><br />
<br />
<table><br />
	<tr><br />
		<td>用户编号</td><br />
		<td>用户名</td><br />
	</tr><br />
<br />
<?php	<br />
if(!empty($_POST["u_num"])){<br />
	$u_num = "where u_id='"."{$_POST['u_num']}"."'";<br />
}<br />
<br />
$sql = "select * from msd.dbo.user";<br />
<br />
$query = sqlsrv_query($conn,$sql);<br />
if( $query === false) {<br />
    die( print_r( sqlsrv_errors(), true) );<br />
}<br />
<br />
while($row = sqlsrv_fetch_array($query)) {<br />
	echo "<tr><td>$row[0]</td><td>$row[1]</td></tr>";<br />
}<br />
<br />
sqlsrv_free_stmt( $query);<br />
sqlsrv_close( $conn);<br />
?><br />
<br />
</table>

PHPexcel 导出 汇出
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn