显示页面
<?php
$conn =mysqli_connect('localhost','root','123456','yitu');
if (!$conn) {
exit('<h1>连接数据库失败</h1>');
}
$query = mysqli_query($conn, 'select * from users;');
if (!$query) {
exit('<h1>查询数据失败</h1>');
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="stylesheet" href="lib/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="Untitled-2.css">
<title>后台管理</title>
</head>
<body>
<div class="container">
<!--导航栏-->
<!--引入多次用到的模板文件-->
<?php include'template.php'?>
<!-- 用户管理导航栏-->
<div class="main-order">
<h3 class="user-h3">用户管理</h3>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">用户列表</a></li>
<li><a href="add.php">添加用户</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<table class="table table-hover">
<thead>
<tr>
<th>序号</th>
<th>会员名称</th>
<th>手机号</th>
<th>会员</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<?php while ($item=mysqli_fetch_array($query)):?>
<th scope="row"><?php echo $item['id']?></th>
<td><?php echo $item['name']?></td>
<td><?php echo $item['number']?></td>
<td><?php echo $item['vip']==0?'新手上路':'易途会员';?></td>
<td>
<div class="dropdown">
<button class="btn btn-itcast dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
操作
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a href="edit.php?id=<?php echo $item['id']?>">编辑</a></li>
<li><a href="delete.php?id=<?php echo $item['id']?>">删除</a></li>
</ul>
</div>
</td>
</tr>
<?php endwhile?>
</tbody>
</table>
</div>
</div>
</div>
</body>
<script src="lib/jquery/jquery.min.js"></script>
<script src="lib/bootstrap/js/bootstrap.min.js"></script>
</html>