Η συνάρτηση mysql_result() του PHP
Ορισμός και χρήση
Η συνάρτηση mysql_result() επιστρέφει την τιμή ενός πεδίου από το σύνολο αποτελεσμάτων.
If successful, the function returns the field value. If failed, it returns false.
Syntax
mysql_result(data,row,field)
Parameters | Description |
---|---|
data | Required. Specify the result identifier to be used. This identifier is returned by the mysql_query() function. |
row | Required. Specify the row number. The row number starts from 0. |
field |
Optional. Specify which field to retrieve. It can be a field offset value, field name, or table.fieldname. If this parameter is not specified, the function retrieves the first field from the specified row. |
Description
When acting on a very large result set, it should be considered to use functions that can retrieve entire rows. These functions return multiple units of content in one function call, much faster than mysql_result().
Additionally, please note that specifying a numeric offset in the field parameter is much faster than specifying a field name or tablename.fieldname.
Example
<?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); ?>
Output similar to:
Adams