Easy Tutorial
❮ Php Mysql Intro Php Session Options ❯

PHP mysqli_data_seek() Function

PHP MySQLi Reference Manual

Seeking data in the result set for row number 3:

// Assuming database username: root, password: 123456, database: tutorialpro
$con = mysqli_connect("localhost", "root", "123456", "tutorialpro");
if (mysqli_connect_errno($con))
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$sql = "SELECT name, url FROM websites ORDER BY alexa";

if ($result = mysqli_query($con, $sql))
{
    // Seek data for row number 3
    mysqli_data_seek($result, 2);

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

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

    // Free result set
    mysqli_free_result($result);
}

mysqli_close($con);
?>

Definition and Usage

The mysqli_data_seek() function adjusts the result pointer to an arbitrary row in the result set.


Syntax

Parameter Description
result Required. Specifies a 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 the total number of rows - 1.

Technical Details

Return Value: Returns TRUE on success, FALSE on failure.
PHP Version: 5+
--- ---
❮ Php Mysql Intro Php Session Options ❯