PHP to get the field name mysql data sheets and detailed property

 

DATABASES SHOW                                 // lists MySQL Server database. 

TABLES SHOW [the FROM db_name]                     // list database tables. 

The CREATE TABLES tbl_name SHOW                     // export the data table structure. 

The STATUS TABLE SHOW [the FROM db_name]               // lists the data table and the state information table. 

The COLUMNS the FROM tbl_name SHOW [the FROM db_name]      // listed in the table field 

SHOW FIELDS FROM tbl_name [FROM db_name] , DESCRIBE tbl_name [col_name]. 

The COLUMNS the FROM tbl_name FULL SHOW [the FROM db_name] // lists the fields and details of 

SHOW FULL the FIELDS the FROM tbl_name [the FROM db_name] // list the complete field attribute 

SHOW INDEX the FROM tbl_name [the FROM db_name]        //The following table lists the index. 

The STATUS SHOW                                   // lists DB Server status. 

VARIABLES SHOW                                // lists the MySQL system environment variables. 

PROCESSLIST SHOW                              // lists execute the command. 

GRANTS the User the FOR SHOW                          // lists a user rights 

DESC TABLE                                   // get more information Table 

1 . 



  Mysql_connect ( " localhost " , " root " , "" ); 

  mysql_select_db ( " the Test " ); 

  $ Query = "desc student";

  $result= mysql_query($query);

  while($row=mysql_fetch_assoc($result)){

 print_r($row);

  }

?>

2.



  mysql_connect("localhost","root","");

  mysql_select_db("test");

  $query= "SHOW FULL COLUMNS FROM student";

  $result= mysql_query($query);

  while($row=mysql_fetch_assoc($result)){

 print_r($row);

  }

?>

3.



  mysql_connect("localhost","root","");

  mysql_select_db("test");

  $query= "SELECT * FROM student LIMIT 1";

  $result= mysql_query($query);

  $fields= mysql_num_fields($result);

  for($count=0;$count<$fields;$count++)

  {

   $field= mysql_fetch_field($result,$count);

  print_r($field);

  }

?>

 

Guess you like

Origin www.cnblogs.com/bluealine/p/11585984.html