PHP's mysql_result() function

WBOY
Release: 2016-07-25 08:52:02
Original
1339 people have browsed it
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



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!