while($row = sqlsrv_fetch_array($query))
<?PHP<br />$serverName = "localhost"; //数据库服务器地址<br /><br />$uid = "sa"; //数据库用户名<br /><br />$pwd = "66"; //数据库密码<br /><br />$connectionInfo = array("UID"=>$uid, "PWD"=>$pwd, "Database"=>"test");<br /><br />$conn = sqlsrv_connect( $serverName, $connectionInfo);<br /><br />if( $conn == false)<br /><br />{<br /> echo "连接失败!";<br /><br /> die( print_r( sqlsrv_errors(), true));<br />}<br />else<br />{<br /> echo "连接成功";<br />//执行有结果集的SQL语句<br /><br /> $query = sqlsrv_query($conn, "select ID,NAME from stuff");<br /><br /> while($row = sqlsrv_fetch_array($query))<br /> {<br /> echo $row[0]."-----".$row[1]."<br/>";<br /><br /> }<br /> sqlsrv_close( $conn);<br /><br />}