Current Location: Home> Function Categories> mysqli_result::data_seek

mysqli_result::data_seek

(mysqli_data_seek) Adjust the result pointer to any row in the result
Name:mysqli_result::data_seek
Category:MySQLi
Programming Language:php
One-line Description:Adjust the result pointer to any row in the result set.

Definition and usage

The mysqli_data_seek() function is used to adjust the result pointer to any row in the result set.

Example

Positioning to line 15 of the result set:

 <?php
$con = mysqli_connect ( "localhost" , "my_user" , "my_password" , "my_db" ) ;
// Check the connection
if ( mysqli_connect_errno ( ) )
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error ( ) ;
  }

$sql = "SELECT Lastname,Age FROM Persons ORDER BY Lastname" ;

if ( $result = mysqli_query ( $con , $sql ) )
  {
  // Position to line 15
  mysqli_data_seek ( $result , 14 ) ;

  // Get row data
  $row = mysqli_fetch_row ( $result ) ;

  printf ( "Lastname: %s Age: %s\n" , $row [ 0 ] , $row [ 1 ] ) ;

  // Release the result set
  mysqli_free_result ( $result ) ;
}

mysqli_close ( $con ) ;
?>

grammar

 mysqli_data_seek ( result , offset ) ;
parameter describe
result Required. Specifies the result set identifier returned by mysqli_query(), mysqli_store_result(), or mysqli_use_result().
offset Required. Specifies the field offset. Must be between 0 and total row count 1.
Similar Functions