定义

mysqli_data_seek()函数将结果指针移动到结果集中的任意一行。

 

语法

PHP mysqli_data_seek()函数具有以下语法。

mysqli_data_seek(result,offset);

 

参数

参数 是否必须 描述
result 需要。 由mysqli_query(),mysqli_store_result()或mysqli_use_result()返回的结果集标识符
offset 需要。 字段偏移。必须介于0和总计行数之间 - 1

 

返回值

成功时返回TRUE,失败时返回FALSE。

 

实例

以下代码指向结果集中的行号15。

<?php
//  http://www.manongjc.com/article/1651.html
$con=mysqli_connect(\"localhost\",\"my_user\",\"my_password\",\"my_db\");

if (mysqli_connect_errno($con)){
  echo \"Failed to connect to MySQL: \" . mysqli_connect_error();
}

$sql=\"SELECT name FROM emp\";

if ($result=mysqli_query($con,$sql)){
  // Seek to row number 15
  mysqli_data_seek($result,14);

  $row=mysqli_fetch_row($result);

  print $row[0];

  mysqli_free_result($result);
}

mysqli_close($con);
?>
收藏 打印