Document directory
Definition and usage
The value of a field in the returned result set returned by the mysql_result () function.
If successful, the function returns the field value. If it fails, false is returned.
Syntax
mysql_result(data,row,field)
| Parameters |
Description |
| Data |
Required. Specifies the result identifier to be used. This identifier is returned by the mysql_query () function. |
| Row |
Required. Specifies the row number. The row number starts from 0. |
| Field |
Optional. Specifies which field to obtain. It can be a field offset value, field name or table. fieldname.
If this parameter is not specified, the function obtains the first field from the specified row. |
Description
For a large result set, you should consider using a function that can obtain the entire row. These functions return the content of multiple units in the callback function call, which is much faster than mysql_result.
In addition, it is much faster to specify the offset in the field parameter than to specify the field name or tablename. fieldname.
Example
Code
<? Php
$ Con= mysql_connect ("localhost", "hello", "321 ");
If (! $ Con)
{
Die ('could not connect: '. mysql_error ());
}
$ Db_selected = mysql_select_db ("test_db", $ con );
$ SQL = "SELECT * from Person ";
$ Result = mysql_query ($ SQL, $ con );
Echo mysql_result ($ result, 0 );
Mysql_close ($ con );
?>
The output is similar:
Adams