Function name: mysqli_result::field_seek()
Applicable version: PHP 5, PHP 7
Function description: the mysqli_result::field_seek() method is used to move the pointer of the result set to the specified field offset.
Syntax: bool mysqli_result::field_seek(int $field_offset)
parameter:
Return value:
Example:
connect_errno) { echo "Connection failed: " . $mysqli->connect_error; exit(); } // Execute the query $query = "SELECT id, name, age FROM users"; $result = $mysqli->query($query); // Check the query result if ($result) { // Move the pointer to the second field $result->field_seek(1); // Get the information of the current field $field = $result->fetch_field(); // Print the field information echo "Field name: " . $field->name . "In the above example, we first create a MySQLi connection and then execute a query statement. Next, we use the mysqli_result::field_seek() method to move the pointer of the result set to the second field (name field). Then, we use the fetch_field() method to get the information of the current field and print it out. Finally, we closed the database connection.
Note: Before using the mysqli_result::field_seek() method, you must execute a query statement and obtain the result set object.