PHP真的是很方便好用哦,轻松得到table中的所有字段:
如下代码,个别地方需要根据自己的具体配置修改
$link=mysql_connect(localhost,root,"")or die("不能连接到服务器".mysql_error());
mysql_select_db(数据库名,$link); //选择相应的数据库,这里选择test库
$result=mysql_query("show columns from 表名");
echo "表中现有的字段内容为:";
while($row=mysql_fetch_array($result)) //遍历表中的所有字段
{
echo $row["Field"];
echo "<p>";
}