查询页面的html和php
<!doctype html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style type="text/css">
    table.imagetable {
        font-family: verdana,arial,sans-serif;
        font-size:11px;
        color:#333333;
        border-width: 1px;
        border-color: #999999;
        border-collapse: collapse;
    }
    table.imagetable th {
        background:#b5cfd2 url('cell-blue.jpg');
        border-width: 1px;
        padding: 8px;
        border-style: solid;
        border-color: #999999;
    }
    table.imagetable td {
        background:#dcddc0 url('cell-grey.jpg');
        border-width: 1px;
        padding: 8px;
        border-style: solid;
        border-color: #999999;
    }
</style>
<body>
<table class="imagetable">
        <tr>
        <th>id</th>
        <th>姓名</th>
        <th>密码</th>
        <th>性别</th>
        <th>系部</th>
        <th>班级</th>
        <th>电话</th>
        </tr>
    <?php
    header( 'Content-Type:text/html;charset=utf-8 ');
    include_once("conn/conn.php");               //引入导入数据库控制页面
    $sql="SELECT*from user";                               //查询数据库中的user;
    $r=mysqli_query($link,$sql);
    $row=mysqli_fetch_array($r);                            //查询出来的数组类型
    while ($row=mysqli_fetch_array($r)){
        /*print_r($row);
        echo "<br>";*/
      /*  echo $row["name"]."=>".$row["mima"];                    //查询姓名和密码   也可以用键来查询
        echo "<br>";*/
    ?>
    <tr>
        <td><?php echo $row["id"]?></td>
        <td><?php echo $row["name"]?></td>
        <td><?php echo $row["mima"]?></td>
        <td><?php echo $row["xingbie"]?></td>                                 <!-- 从数据库中查询出的数据装着表格中-->
        <td><?php echo $row["xibu"]?></td>
        <td><?php echo $row["banji"]?></td>
        <td><?php echo $row["tex"]?></td>
    </tr>
<?php
    }
?>
</table>
</body>
</html>
数据库中的PHP代码
<?php
$host="localhost";//规定主机名和ip地址
$db_user="root"; //数据库用户
$db_pass="";    //数据库密码
$db_name="sqlclass1";   //要使用的数据库数据库
$timezone = "Asia/Shanghai";//上海时间
$link=mysqli_connect($host,$db_user,$db_pass,$db_name);//mysqli_connect打开一个到 MySQL 服务器的新的连接
mysqli_query($link,"SET names UTF8");//link  是规定要使用的mysql连接       后面是设置编码格式
header("Content-Type: text/html; charset=utf-8");
date_default_timezone_set($timezone); //北京时间
?>