FOR in php and sqlsrv

0

I have to make a FOR in PHP using SQLSRV. I'm using the penultimate version of PHP and not the last one, as I can not update PHP.

    
asked by anonymous 05.11.2014 / 17:32

1 answer

3

Something you can use is sqlsrv_fetch_array

$sql = "SELECT FirstName, LastName FROM SomeTable";
$stmt = sqlsrv_query( $conn, $sql );
if( $stmt === false) {
    die( print_r( sqlsrv_errors(), true) );
}

while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC) ) {
          echo $row['LastName'].", ".$row['FirstName']."<br />";
}
    
05.11.2014 / 17:40