$link = mysqli_connect("localhost", "root", "",$database);
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$sql = "SHOW COLUMNS FROM area";
$query = mysqli_query($link,$sql);
echo '<pre>'; print_r(mysqli_fetch_array($query));
以上是我的代码,它只返回id(第一个字段)
答案 0 :(得分:0)
编辑:我的不好,抱歉。
如MySQLi examples on PHP.net所示,您希望了解结果;你的代码看起来像:
$link = new mysqli("localhost", "root", "", $database);
$cursor = $link->query('SHOW COLUMNS FROM area;');
while ($row = $cursor->fetch_assoc())
{
print_r($row);
}
答案 1 :(得分:0)
你必须像这样获取所有行
$link = mysqli_connect("localhost", "root", "",$database);
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
$sql = "SHOW COLUMNS FROM area";
$query = mysqli_query($link,$sql);
echo '<pre>';
while ($res = mysqli_fetch_array($query)){
print_r($res);
}
echo '</pre>';