<?php
header("content-type:text/html;charset=utf-8");
$link=mysqli_connect('localhost:3306','root','zxc111','wl');
mysqli_set_charset($link,'utf8');
if (mysqli_connect_error($link)){
    die('连接失败'.mysqli_connect_error($link));
}else{
    echo "<p>连接成功</p>";
}
$sql='SELECT * FROM `stu1`';
$result=mysqli_query($link,$sql);
if ($result && mysqli_num_rows($result)>0){
    //获取当前所有的字段信息,返回对象数组
    $fields=mysqli_fetch_fields($result);
    echo '<pre/>';
    print_r($fields);
}
#获取单独的某个字段的信息
echo "<hr>";
echo '获取指定字段的信息';
$field=mysqli_fetch_field_direct($result,'0');
echo '当前字段的name属性是:'.$field->name;
?>