<meta charset="utf-8">
<?php
//连接数据库
$db = new MySQLi('localhost','root','','php');
!mysqli_connect_error() or die('连接失败');
$db->query('set names utf8');
//判断
if(!empty($_GET['id'])){
$sql="delete from student where sno=".$_GET['id'];
$res=$res->query($sql);
}
//查找库里的内容
$sql='select * from student';
$res=$db->query($sql);
$arr=$res->fetch_all();
?>
//这个事添加按钮
<a href="ye_3.php">添加</a>
//这是个表
<table width="100%" border="1" cellpadding="0" cellspacing="0">
<tr>
<th>学号</th>
<th>姓名</th>
<th>性别</th>
<th>生日</th>
<th>班级</th>
<th>操作</th>
</tr>
//把库中的内容添加到表中
<?php foreach($arr as $i){?>
<tr>
<td><?php echo $i[0]; ?></td>
<td><?php echo $i[1]; ?></td>
<td><?php echo $i[2]; ?></td>
<td><?php echo $i[3]; ?></td>
<td><?php echo $i[4]; ?></td>
<td>
//删除以及修改按钮
<a href="ye_1.php">删除</a>
<a href="ye_2.php">修改</a>
</td>
</tr>
<?php }?>
</table>
</body>
</html>
在页面2中进行一下操作
<meta charset="utf-8">
//首先连接数据库
<?php
$db = new MySQLi('localhost','root','','php');
!mysqli_connect_error() or die('连接失败');
$db->query('set names utf8');
//定义常量
$sno = $_POST['sno'];
$sname = $_POST['sname'];
$ssex = $_POST['ssex'];
$sbirthday = $_POST['sbirthday'];
$clsaa = $_POST['clsaa'];
$sql = "insert into student values('$sno','$sname','$ssex','$sbirthday','$clsaa')";
$res = $db->query($sql);
//进行判断,添加内容
if($res){
header('location:ye_1.php');
}else{
header('location:ye_2.php');
}
?>
第三个页面写需要填写表的内容
//from表单进行添加内容,传值到页面2
<form action="ye_2.php" method="post">
编号:<input type="text" name="sno"><br>
姓名:<input type="text" name="sname"><br>
性别:<input type="text" name="ssex"><br>
生日:<input type="text" name="sbirthday"><br>
班级:<input type="text" name="clsaa"><br>
<button>提交</button>
</form>