PHP mysqli_data_seek () function
In the result set of data to find the row number 3:
// 假定数据库用户名:root,密码:123456,数据库:w3big $con=mysqli_connect("localhost","root","123456","w3big"); 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)) { //查找行号为 3 的数据 mysqli_data_seek($result,2); // 读取数据 $row=mysqli_fetch_row($result); printf ("name: %s url: %sn", $row[0], $row[1]); // 释放结果集 mysqli_free_result($result); } mysqli_close($con); ?>
Definition and Usage
mysqli_data_seek () function to adjust the result pointer to an arbitrary row in the result set.
grammar
mysqli_data_seek( result,offset ) ;
参数 | 描述 |
---|---|
result | 必需。规定由 mysqli_query()、mysqli_store_result() 或 mysqli_use_result() 返回的结果集标识符。 |
offset | 必需。规定字段偏移。范围必须在 0 和 行总数 - 1 之间。 |
technical details
return value: | If successful it returns TRUE, on failure returns FALSE. |
---|---|
PHP version: | 5+ |
PHP MySQLi Reference Manual