PHP's mysql_result() function
Definition and usage mysql_result() function returns the value of a field in the result set. If successful, the function returns the field value. On failure, returns false. Grammar mysql_result(data,row,field) Parameter Description data required. Specifies the result identifier to use. This identifier is returned by the mysql_query() function. row required. Specify the line number. Line numbers start from 0. field is optional. Specifies which field to obtain. Can be a field offset value, field name or table.fieldname. If this parameter is not specified, the function gets the first field from the specified row. Instructions When working with very large result sets, you should consider using functions that retrieve entire rows. These functions return the contents of multiple units in a single function call, much faster than mysql_result(). Also note that specifying a numeric offset in the field parameter is much faster than specifying the 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); ?> Copy after login The output is similar to: Adams |