In the application
The PHP Get table field name is implemented by the Mysql_field_name () function, which has the following syntax format:
String Mysql_field_name (resource $result, int $field _offset)
The Mysql_field_name () function returns the name of the field for the specified index, and its parameters are described below.
L Result:mysql_query () The result set returned after the function is executed.
L Field_offset: The offset of the field with a starting value of zero.
The example code for getting table field names using PHP with the Mysql_field_name () function is as follows:
- < ? PHP
- $ Connection = mysql_connect ("localhost",
"Root", "root") or Die ("Connection Server failed");
- mysql_select_db ("Sunyang", $connection)
Or Die ("Select Database Failed");
- $ Query = "SELECT * FROM Employee" ;
- $ result = mysql_query ($query) or
Die ("Query user failed");
- Echo mysql_field_name ($result, 0);
Output first field name
- echo " <br> ";
- Echo Mysql_field_name ($result, 1);
Output second field name
- Mysql_close ($connection);
- ?>
The first field name and second field name can be output in the PHP Get table fields name code above.
http://www.bkjia.com/PHPjc/445930.html www.bkjia.com true http://www.bkjia.com/PHPjc/445930.html techarticle using PHP to get the table field name is implemented by the Mysql_field_name () function, which has the following syntax format: String mysql_field_name (Resource $result, int $field _offset) Mysql_fie ...