Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mssql_num_fields(3) [php man page]

MSSQL_NUM_FIELDS(3)													       MSSQL_NUM_FIELDS(3)

mssql_num_fields - Gets the number of fields in result

SYNOPSIS
int mssql_num_fields (resource $result) DESCRIPTION
mssql_num_fields(3) returns the number of fields in a result set. PARAMETERS
o $result - The result resource that is being evaluated. This result comes from a call to mssql_query(3). RETURN VALUES
Returns the number of fields, as an integer. EXAMPLES
Example #1 mssql_num_fields(3) example <?php // Connect to MSSQL and select the database $link = mssql_connect('KALLESPCSQLEXPRESS', 'sa', 'phpfi'); mssql_select_db('php', $link); // Select some data from our database $data = mssql_query('SELECT [name], [age] FROM [php].[dbo].[persons]'); // Construct a table echo '<table border="1">'; $header = false; // Iterate through returned results while ($row = mssql_fetch_array($data)) { // Build the table header if (!$header) { echo '<thead>'; echo '<tr>'; for ($i = 1; ($i + 1) <= mssql_num_fields($data); ++$i) { echo '<td>' . ucfirst($row[$i]) . '</td>'; } echo '</tr>'; echo '</thead>'; echo '<tbody>'; $header = true; } // Build the row echo '<tr>'; foreach($row as $value) { echo '<td>' . $value . '</td>'; } echo '</tr>'; } // Close table echo '</tbody>'; echo '</table>'; // Clean up mssql_free_result($data); mssql_close($link); ?> SEE ALSO
mssql_query(3), mssql_fetch_field(3), mssql_num_rows(3). PHP Documentation Group MSSQL_NUM_FIELDS(3)

Check Out this Related Man Page

SQLSRV_NEXT_RESULT(3)													     SQLSRV_NEXT_RESULT(3)

sqlsrv_next_result - Makes the next result of the specified statement active

SYNOPSIS
mixed sqlsrv_next_result (resource $stmt) DESCRIPTION
Makes the next result of the specified statement active. Results include result sets, row counts, and output parameters. PARAMETERS
o $stmt - The statment on which the next result is being called. RETURN VALUES
Returns TRUE if the next result was successfully retrieved, FALSE if an error occurred, and NULL if there are no more results to retrieve. EXAMPLES
Example #1 sqlsrv_next_result(3) example The following example executes a batch query that inserts into a table and then selects from the table. This produces two results on the statement: one for the rows affected by the INSERT and one for the rows returned by the SELECT. To get to the rows returned by the SELECT, sqlsrv_next_result(3) must be called to move past the first result. <?php $serverName = "serverNamesqlexpress"; $connectionInfo = array("Database"=>"dbName", "UID"=>"userName", "PWD"=>"password"); $conn = sqlsrv_connect( $serverName, $connectionInfo); $query = "INSERT INTO Table_1 (id, data) VALUES (?,?); SELECT * FROM TABLE_1;"; $params = array(1, "some data"); $stmt = sqlsrv_query($conn, $query, $params); // Consume the first result (rows affected by INSERT) without calling sqlsrv_next_result. echo "Rows affected: ".sqlsrv_rows_affected($stmt)."<br />"; // Move to the next result and display results. $next_result = sqlsrv_next_result($stmt); if( $next_result ) { while( $row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)){ echo $row['id'].": ".$row['data']."<br />"; } } elseif( is_null($next_result)) { echo "No more results.<br />"; } else { die(print_r(sqlsrv_errors(), true)); } ?> SEE ALSO
sqlsrv_query(3), sqlsrv_fetch_array(3), sqlsrv_rows_affected(3). PHP Documentation Group SQLSRV_NEXT_RESULT(3)
Man Page