PHP mysqli_data_seek() Function
Find the row with row number 3 in the result set:
// Assume database username: root, password: 123456, database: RUNOOB
$con=mysqli_connect("localhost","root","123456","RUNOOB");
if (mysqli_connect_errno($con))
{
echo "连接 MySQL 失败: " . mysqli_connect_error();
}
$sql="SELECT name,url FROM websites ORDER BY alexa";
if ($result=mysqli_query($con,$sql))
{
//Find data at line number 3
mysqli_data_seek($result,2);
// Read data
$row=mysqli_fetch_row($result);
printf ("name: %s url: %sn", $row[0], $row[1]);
// Release the result set
mysqli_free_result($result);
}
mysqli_close($con);
?>
Definition and Usage
The mysqli_data_seek() function moves the result pointer to an arbitrary row in the result set.
Syntax
mysqli_data_seek(
result,offset
)
;
| Parameters | Description |
|---|---|
| result | Required. Specifies the result set identifier returned by mysqli_query(), mysqli_store_result(), or mysqli_use_result(). |
| offset | Required. Specifies the field offset. The range 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 MySQLi Reference Manual