sqlsrv_num_fields(3) php man page | unix.com

Man Page: sqlsrv_num_fields

Operating Environment: php

Section: 3

SQLSRV_NUM_FIELDS(3)													      SQLSRV_NUM_FIELDS(3)

sqlsrv_num_fields - Retrieves the number of fields (columns) on a statement

SYNOPSIS
mixed sqlsrv_num_fields (resource $stmt)
DESCRIPTION
Retrieves the number of fields (columns) on a statement.
PARAMETERS
o $stmt - The statment for which the number of fields is returned. sqlsrv_num_fields(3) can be called on a statement before or after statement execution.
RETURN VALUES
Returns the number of fields on success. Returns FALSE otherwise.
EXAMPLES
Example #1 sqlsrv_num_fields(3) example <?php $serverName = "serverNamesqlexpress"; $connectionInfo = array( "Database"=>"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 "<br />"; } ?>
SEE ALSO
sqlsrv_field_metadata(3), sqlsrv_fetch(3), sqlsrv_get_field(3). PHP Documentation Group SQLSRV_NUM_FIELDS(3)
Related Man Pages
sqlsrv_query(3) - php
sqlsrv_execute(3) - php
sqlsrv_fetch_array(3) - php
sqlsrv_next_result(3) - php
sqlsrv_num_fields(3) - php
Similar Topics in the Unix Linux Community
sql in shell script
How to redirect value from sql select statment to unix variable
If statement is not working in KSH
Problem comparing String using IF stmt
If echo statement return false