note 39623 added to function.mysql-data-seek
| From: | andy at suffl dot com | Date: | Thu, 05 Feb 2004 00:24:01 +0000 |
| Subject: | note 39623 added to function.mysql-data-seek | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-64657@lists.php.net to get a copy of this message | ||
mysql_data_seek is nice to move the pointer to an absolute row number, but since it seems there is
no function that returns the row number that the internal row pointer is currently pointing to, you
can't move X rows forward or backward relative to the current row. You could keep track of
that number yourself, but it would be easier to have a function (let's call it mysql_rownumber)
return the current row number.
A motivating example: I have a script that outputs blog entries and prints " * * * "
after each, but I don't want that printed after the very last one on the page.
I would like to have:
if (mysql_rownumber($result) < mysql_num_rows($result)-1)
print " * * * ";
so that the asterisks don't get printed after the last. (Say mysql_num_rows returned 8; then
mysql_rownumber would return 0-7 as the loop iterates thus the -1.)
This would also be useful in determining whether the current row is odd or even, displaying data in
columns, and probably some other uses.
----
Manual Page -- http://www.php.net/manual/en/function.mysql-data-seek.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39623
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39623&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39623&report=yes
Search -- http://master.php.net/manage/user-notes.php