Home > php教程 > php手册 > 在php中 取得mysql 列信息的两种方法

在php中 取得mysql 列信息的两种方法

WBOY
Release: 2016-06-13 09:40:39
Original
1197 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 {
$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'];
}


source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template