Home > Backend Development > PHP Tutorial > Two methods to obtain mysql column information in php_PHP tutorial

Two methods to obtain mysql column information in php_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:28:07
Original
1171 people have browsed it

   1、使用mysql_fetch_field

  $query=$db->query(" SELECT * FROM $tablename limit 1");

  $num=mysql_num_fields($query);

  for($i=0;$i<$num;$i++)

  {

  $f_db=mysql_fetch_field($query,$i);

  $showdb[]=$f_db->name;

  }

  2、使用show fields

  $sqlr="show fields from $tablename";

  $query=mysql_query($sqlr);

  while($row=mysql_fetch_array($query))

  {

  print_r($row);

  $data[]=$row['Field'];

  }

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/814668.htmlTechArticle1、使用mysql_fetch_field $query=$db-query( SELECT * FROM $tablename limit 1); $num=mysql_num_fields($query); for($i=0;$i$num;$i++) { $f_db=mysql_fetch_field($query,$i); $showdb[...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Error when importing traits
From 1970-01-01 08:00:00
0
0
0
Why did the teacher’s submission fail?
From 1970-01-01 08:00:00
0
0
0
Laravel Modal does not return data
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template