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