Home  >  Article  >  Backend Development  >  PHP怎么将查询结束导出Excel

PHP怎么将查询结束导出Excel

WBOY
WBOYOriginal
2016-06-13 12:41:58877browse

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 导出 汇出
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn