Oracle 5.0 Reference Manual page 2271

Table of Contents

Advertisement

Description
bool mysql_data_seek(
resource result,
int row_number);
moves the internal row pointer of the MySQL result associated with the specified
mysql_data_seek
result identifier to point to the specified row number. The next call to a MySQL fetch function, such as
mysql_fetch_assoc, would return that row.
starts at 0. The
row_number
- 1. However if the result set is empty
mysql_num_rows
with a
E_WARNING
and
Parameters
result
row_number
Return Values
Returns
on success or
TRUE
Examples
Example 20.31.
mysql_data_seek
<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db('sample_db');
if (!$db_selected) {
die('Could not select database: ' . mysql_error());
}
$query = 'SELECT last_name, first_name FROM friends';
$result = mysql_query($query);
if (!$result) {
die('Query failed: ' . mysql_error());
}
/* fetch rows in reverse order */
for ($i = mysql_num_rows($result) - 1; $i >= 0; $i--) {
if (!mysql_data_seek($result, $i)) {
echo "Cannot seek to row $i: " . mysql_error() . "\n";
continue;
}
if (!($row = mysql_fetch_assoc($result))) {
continue;
}
echo $row['last_name'] . ' ' . $row['first_name'] . "<br />\n";
}
mysql_free_result($result);
?>
Notes
Note
The function
mysql_query, not with mysql_unbuffered_query.
Original MySQL API (Mysql)
should be a value in the range from 0 to
row_number
will return
mysql_data_seek
The result resource that is being evaluated. This result comes from
a call to mysql_query.
The desired row number of the new result pointer.
on failure.
FALSE
example
mysql_data_seek
2251
(mysql_num_rows
.
FALSE
can be used in conjunction only with
== 0), a seek to 0 will fail

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents