Current Location: Home> Function Categories> mysql_result

mysql_result

Obtain the result data.
Name:mysql_result
Category:Uncategorized
Programming Language:php
One-line Description:Use MySQL extension (mysql, mysqli) for database operations, not applicable to PDO extension

Function name: mysql_result()

Applicable version: PHP 4, PHP 5

Function usage: mysql_result(resource $result, int $row, mixed $field)

Parameter description:

  • $result: The resource identifier representing the database query result.
  • $row: represents the line number in the result set. Line numbers start counting from 0.
  • $field: represents the field name or field index in the result set. Field index counts from 0.

Return value: Returns the value of the specified row and field when successful, and returns false when failure.

Function example:

 // 假设已经连接到数据库并执行了查询操作$result = mysql_query("SELECT * FROM users"); // 获取结果集中第一行、第二个字段的值$value = mysql_result($result, 0, 1); echo $value; // 输出第一行、第二个字段的值// 获取结果集中第三行、"username"字段的值$value = mysql_result($result, 2, "username"); echo $value; // 输出第三行、"username"字段的值

Notes:

  • This function is only suitable for database operations using MySQL extension (mysql, mysqli), and is not suitable for PDO extensions.
  • In PHP 5.5.0, this function is marked as deprecated and it is recommended to use mysqli or PDO instead.
  • In PHP version 7.0.0, the function has been removed and is no longer available. It is recommended to use mysqli or PDO extensions to operate the database.
Similar Functions
Popular Articles