Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mysqli_num_fields(3) [php man page]

MYSQLI_NUM_FIELDS(3)							 1						      MYSQLI_NUM_FIELDS(3)

mysqli_result::$field_count - Get the number of fields in a result

       Object oriented style

SYNOPSIS
int$mysqli_result->field_count () DESCRIPTION
Procedural style int mysqli_num_fields (mysqli_result $result) Returns the number of fields from specified result set. PARAMETERS
o $ result -Procedural style only: A result set identifier returned by mysqli_query(3), mysqli_store_result(3) or mysqli_use_result(3). RETURN VALUES
The number of fields from a result set. EXAMPLES
Example #1 Object oriented style <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } if ($result = $mysqli->query("SELECT * FROM City ORDER BY ID LIMIT 1")) { /* determine number of fields in result set */ $field_cnt = $result->field_count; printf("Result set has %d fields. ", $field_cnt); /* close result set */ $result->close(); } /* close connection */ $mysqli->close(); ?> Example #2 Procedural style <?php $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } if ($result = mysqli_query($link, "SELECT * FROM City ORDER BY ID LIMIT 1")) { /* determine number of fields in result set */ $field_cnt = mysqli_num_fields($result); printf("Result set has %d fields. ", $field_cnt); /* close result set */ mysqli_free_result($result); } /* close connection */ mysqli_close($link); ?> The above examples will output: Result set has 5 fields. SEE ALSO
mysqli_fetch_field(3). PHP Documentation Group MYSQLI_NUM_FIELDS(3)

Check Out this Related Man Page

MYSQLI_FETCH_ROW(3)							 1						       MYSQLI_FETCH_ROW(3)

mysqli_result::fetch_row - Get a result row as an enumerated array

       Object oriented style

SYNOPSIS
mixed mysqli_result::fetch_row (void ) DESCRIPTION
Procedural style mixed mysqli_fetch_row (mysqli_result $result) Fetches one row of data from the result set and returns it as an enumerated array, where each column is stored in an array offset starting from 0 (zero). Each subsequent call to this function will return the next row within the result set, or NULL if there are no more rows. PARAMETERS
o $ result -Procedural style only: A result set identifier returned by mysqli_query(3), mysqli_store_result(3) or mysqli_use_result(3). RETURN VALUES
mysqli_fetch_row(3) returns an array of strings that corresponds to the fetched row or NULL if there are no more rows in result set. Note This function sets NULL fields to the PHP NULL value. EXAMPLES
Example #1 Object oriented style <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5"; if ($result = $mysqli->query($query)) { /* fetch object array */ while ($row = $result->fetch_row()) { printf ("%s (%s) ", $row[0], $row[1]); } /* free result set */ $result->close(); } /* close connection */ $mysqli->close(); ?> Example #2 Procedural style <?php $link = mysqli_connect("localhost", "my_user", "my_password", "world"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } $query = "SELECT Name, CountryCode FROM City ORDER by ID DESC LIMIT 50,5"; if ($result = mysqli_query($link, $query)) { /* fetch associative array */ while ($row = mysqli_fetch_row($result)) { printf ("%s (%s) ", $row[0], $row[1]); } /* free result set */ mysqli_free_result($result); } /* close connection */ mysqli_close($link); ?> The above examples will output: Pueblo (USA) Arvada (USA) Cape Coral (USA) Green Bay (USA) Santa Clara (USA) SEE ALSO
mysqli_fetch_array(3), mysqli_fetch_assoc(3), mysqli_fetch_object(3), mysqli_query(3), mysqli_data_seek(3). PHP Documentation Group MYSQLI_FETCH_ROW(3)
Man Page