Introduction
In this article I describe the PHP MySQLi functions mysqli_field_seek, mysqli_field_tell, mysqli_free_result, mysqli_get_charset and mysqli-get_client_info. To learn some other MySQLi functions, go to:
- MySQLi Function in PHP: Part 1
- MySQLi Function in PHP: Part 2
- MySQLi Function in PHP: Part 3
- MySQLi Function in PHP: Part 4
- MySQLi Function in PHP: Part 5
PHP mysqli_field_seek() Function
The PHP MySQLi "mysqli_field_seek" function sets the field cursor to a specified field offset and this function returns true on success or false on failure.
Syntax
| mysqli_field_seek(result,fieldnr) |
Parameter in mysqli_field_seek function
The parameters of the function are:
| Parameter | Description |
| result | It specifies a result set identifier returned by mysqli_query(), mysqli_store_result() or mysqli_user_result(). |
| fieldnr | It specifies the field number and this number must be an integer between 0 and number of field -1. |
Example
An example of the function is:
<?php
$con=mysqli_connect("localhost","root","","mysql");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if($result=mysqli_query($con,"SELECT * FROM emp"))
{
mysqli_field_seek($result,0);
$info=mysqli_fetch_field($result);
printf("<b>Emp Name: </b>%s",$info->name);
echo "<br>";
printf("<b>Table Name: </b>%s",$info->table);
echo "<br>";
printf("<b>max. Len:</b> %d\n",$info->max_length);
}
mysqli_close($con);
?>
Output

PHP mysqli_field_tell() Function
The PHP MySQLi "mysqli_field_tell" function returns the position of the field cursor or in other words this function returns the current offset of the field cursor on success.
Syntax
| mysqli_field_tell(result) |
Parameter in mysqli_field_seek function
The parameter of the function is:
| Parameter | Description |
| result | It specifies a result set identifier returned by mysqli_query(), mysqli_store_result() or mysqli_user_result(). |
Example
An example of the function is:
<?php
$con=mysqli_connect("localhost","root","","mysql");
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if($result=mysqli_query($con,"SELECT * FROM emp"))
{
mysqli_field_seek($result,0);
while($info=mysqli_fetch_field($result))
{
$currentField=mysqli_field_tell($result);
echo "<h1>Column". $currentField."</h1>";
printf("<b>Column Name: </b>%s",$info->name);
printf("<b> Table Name: </b>%s",$info->table);
printf("<b> max. Len:</b> %d\n",$info->max_length);
echo "<br>";
}
}
mysqli_close($con);
?>
Output
PHP mysqli_free_result() Function
The PHP MySQLi "mysqli_free_result" function frees memory associated with a result and this function returns true on success or false on failure.
Syntax




Join the conversation! Your thoughts help the community grow.