sqlsrv_num_fields Retrieves the number of fields (columns) on a statement &reftitle.description; mixedsqlsrv_num_fields resourcestmt Retrieves the number of fields (columns) on a statement. &reftitle.parameters; stmt The statment for which the number of fields is returned. sqlsrv_num_fields can be called on a statement before or after statement execution. &reftitle.returnvalues; Returns the number of fields on success. Returns &false; otherwise. &reftitle.examples; <function>sqlsrv_num_fields</function> example "dbName", "UID"=>"username", "PWD"=>"password"); $conn = sqlsrv_connect( $serverName, $connectionInfo); if( $conn === false ) { die( print_r( sqlsrv_errors(), true)); } $sql = "SELECT * FROM Table_1"; $stmt = sqlsrv_query($conn, $sql); if( $stmt === false) { die( print_r( sqlsrv_errors(), true)); } $numFields = sqlsrv_num_fields( $stmt ); while( sqlsrv_fetch( $stmt )) { // Iterate through the fields of each row. for($i = 0; $i < $numFields; $i++) { echo sqlsrv_get_field($stmt, $i)." "; } echo "
"; } ?> ]]>
&reftitle.seealso; sqlsrv_field_metadata sqlsrv_fetch sqlsrv_get_field