mysql_data_seek()

It moves the record pointer

MySQL Table – Users

+—-+——+
| id | name |
+—-+——+
|  1 | PHP  |
|  2 | JS   |
|  3 | HTML |
|  4 | AS   |
+—-+——+

Example

<?php
$conn = mysql_connect(“localhost”, “root”, “password”) or die(mysql_error());
mysql_select_db(“database_name”,$conn);
$userInfo = mysql_query(“SELECT * from users”);
echo “<pre>”;
print_r(mysql_fetch_row($userInfo));
mysql_data_seek($userInfo,3);
print_r(mysql_fetch_row($userInfo));
mysql_close($conn);
?>

Output

Array
(
[0] => 1
[1] => PHP
)
Array
(
[0] => 4
[1] => AS
)

Share