Re: mysql_result(), Unable to jump to row 1 on MySQLresult
| From: | php4 at developersdesk dot com | Date: | Tue, 11 Jul 2000 00:15:21 +0000 |
| Subject: | Re: mysql_result(), Unable to jump to row 1 on MySQLresult | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-24162@lists.php.net to get a copy of this message | ||
Addressed to: =?iso-8859-1?Q?Andr=E9?= Langhorst <A.Langhorst@itbnet.de>
php-dev@lists.php.net
** Reply to note from =?iso-8859-1?Q?Andr=E9?= Langhorst <A.Langhorst@itbnet.de> Mon, 10 Jul
2000 13:46:14 +0200
>
> >
> > isn't the first row 0?
> > try mysql_result($result,0)
> >
> > and should mysql_result need an parameter for the field to get?
>
> 1) AFAIK row numbers start at 1
> 2) third param is optional
I use mysql_result() probably too often...
Row numbers start at 0. I usually do something like:
$I = 0;
$Count = mysql_num_rows( $Result );
while( $I < $Count ) {
$Variable = mysql_Result( $Result, $I, 'Variable' );
}
From the manual...
-------------------------------------------------------
int mysql_result (int result, int row [, mixed field])
mysql_result() returns the contents of one cell from a MySQL result
set. The field argument can be the field's offset, or the field's name,
or the field's table dot field's name (fieldname.tablename). If the
column name has been aliased ('select foo as bar from...'), use the
alias instead of the column name.
-------------------------------------------------------
The way I read that, the field param is only optional in that you can
specify the field many ways. You have to tell it what field to return
somehow, so I think it is a required field, you just have an option on
how to specify the field.
Maybe the [ ] around the field param should be removed from the manual.
Rick Widmer
Internet Marketing Specialists
http://www.developersdesk.com