Sincerely thank you Marvin for your help. If you don't mind, I would like to step some more for this obviously basic topic but for me it is something else.
I'm from Vfp Db world that Vfp provides single line functions a lot. In this case, as I've selected a record(row), then all I need to code is 'skip' to get next record(row) and -skip -3 for 3 steps back ...
I read the example you pointed to:
. . . .
$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);
?>
I need help to understand:
(1) Since the current row is known by the first seek, then all I need to save row() to a global var somewhere, so I just row()+1 for next row and row()-1 for previous... for me it is not necessary to go thru a 'for' loop to fetch + or - the row... do you think it could work that way on php/mySql? if so, how?
(2) It seem [mysql_free_result($result);] is to empty $result or what?
Thanks again.
Best reguards,
Chin