When using
PHP to obtain the table field name is implemented 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_field_name() function will return the name of the field at 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 the field, starting from zero.
The sample code for PHP to get the table field name using the mysql_field_name() function is as follows:
- < ?php
- $connection= mysql_connect("localhost",
"root","root") or die("Failed to connect to server"); - mysql_select_db("sunyang",$connection)
or die("Failed to select database"); - $query="select * from employee";
- $ result=mysql_query($query) or
die(" Failed to query user"); - echo mysql_field_name($result,0);
//Output the first field name - echo "<br>";
- echo mysql_field_name($result,1);
//Output the second field name - mysql_close($connection);
-
?>
Get it in PHP above The first field name and the second field name can be output in the table field name code.
http://www.bkjia.com/PHPjc/445930.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445930.htmlTechArticleUsing PHP to obtain the table field name is implemented 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...