Php/func mysqli data seek
来自菜鸟教程
PHP mysqli_data_seek()函数
例
在结果集中寻找第15行:
<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check 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))
{
// Seek to row number 15
mysqli_data_seek($result,14);
// Fetch row
$row=mysqli_fetch_row($result);
printf ("Lastname: %s Age: %s\n", $row[0], $row[1]);
// Free result set
mysqli_free_result($result);
}
mysqli_close($con);
?>
定义和用法
mysqli_data_seek()函数将结果指针调整为结果集中的任意行。
句法
mysqli_data_seek(result,offset);
参数值
| 参数 | 描述 |
|---|---|
| result | 需要。指定mysqli_query(),mysqli_store_result()或mysqli_use_result()返回的结果集标识符 |
| offset | 需要。指定字段偏移量。必须在0到总行数之间-1 |
技术细节
| 返回值: | 成功则为真。失败时为假 |
| PHP版本: | 5+ |