Use the appropriate function to implement PHP to obtain the table field name. You can use the mysql_field_name () function to obtain the table field name using PHP. the syntax format of this function is as follows: stringmysql_field_name (resource $ result, int $ field_offset) mysql_fie is used.
PHP obtains the table field name through the mysql_field_name () function. the syntax format of this function is as follows:
String mysql_field_name (resource $ result, int $ field_offset)
The mysql_field_name () function returns the name of the field of the specified index. its parameters are described as follows.
L result: the result set returned after the mysql_query () function is executed.
L field_offset: the offset of a field. the start value is zero.
Use the PHP function of mysql_field_name () to obtain the table field name. The sample code is as follows:
- <? Php
- $ Connection = mysql_connect ("localhost ",
"Root", "root") or die ("failed to connect to the server ");
- Mysql_select_db ("sunyang", $ connection)
Or die ("failed to select database ");
- $ Query = "select * from employee ";
- $ Result = mysql_query ($ query) or
Die ("user query failed ");
- Echo mysql_field_name ($ result, 0 );
// Output the first field name
- Echo"
";
- Echo mysql_field_name ($ result, 1 );
// Output the second field name
- Mysql_close ($ connection );
- ?>
In the above PHP code, the first and second field names can be output.
PHP obtains the table field name through the mysql_field_name () function. the syntax format of this function is as follows: string mysql_field_name (resource $ result, int $ field_offset) mysql_fie...