删除的连接为01171015_ opt.php?stuid=&action=del,传入对应学生的学号
处理学生信息。在07110108_opt.php中编写逻辑,根据传过来的action参数,调用不同的处理函数
1. 删除学生:01171015_ opt.php?stuid=&action=del

调用删除函数,删除此学生
2. 增加学生:01171015_ opt.php?stuid=&action=add
调用07110108_stu.php,修正提交到07110108_ opt.php? action=add
根据填入数据,增加学生。
01171015_ opt.php:
<?phprequire './01171015_init.php';$opt =isset($_GET['opt'])?$_GET['opt']:'';$id =isset($_GET['id'])?$_GET['id']:'';$sql = '';$tem = '';if($opt=='del'){//删除$sql = \"大众delete from tb_stuinf where stu_id='\"大众.$id.\"大众'\公众;$tem = 'delete';}else {//添加$stu_id = isset($_POST['stu_id'])?$_POST['stu_id']:''; //学号$stu_name = isset($_POST['stu_name'])?$_POST['stu_name']:''; //名字$class_id = isset($_POST['class_id'])?$_POST['class_id']:'';//班级$stu_gender = isset($_POST['stu_gender'])?$_POST['stu_gender']:''; //性别$stu_birth = $_POST['year'].'-'.$_POST['math'].'-'.$_POST['day'];//日期$stu_hobby = isset($_POST['stu_hobby'])?$_POST['stu_hobby']:'';$strs = implode(\"大众 \"大众,$stu_hobby); //爱好$stu_role = isset($_POST['stu_role'])?$_POST['stu_role']:'';//角色$stu_phone = isset($_POST['stu_phone'])?$_POST['stu_phone']:'';//电话号码$stu_password = isset($_POST['stu_password'])?$_POST['stu_password']:'';//密码if($opt == 'add'){$sql = \"大众INSERT INTO `tb_stuinf`(`stu_id`, `stu_name`, `class_id`, `stu_gender`, `stu_birth`, `stu_hobby`, `stu_role`, `stu_phone`, `stu_password`) VALUES ('\公众.$stu_id.\"大众','\公众.$stu_name.\公众','\"大众.$class_id.\公众','\"大众.$stu_gender.\公众','\"大众.$stu_birth.\公众','\"大众.$strs.\公众','\"大众.$stu_role.\"大众','\"大众.$stu_phone.\公众','\"大众.$stu_password.\"大众')\"大众;$tem = \"大众add\公众;}}db_oper($sql) ;$msg='';if($tem == 'delete'){$msg='删除成功';}else if($tem == 'add'){$msg = '插入成功';}else if($tem == 'update'){$msg = '更新成功';}else{$msg=\"大众操作失落败,请规范操作\公众;}echo \"大众<script>alert('$msg');</script>\公众;echo \"大众<script>window.location.href='01171015_list.php';</script>\"大众;
PS:在里面我们可以直策应用MySQL里面的实行
可以自己去学习,链接不才面的扩展。
二、我们还须要再创建一个文件夹在前面的教室里面我们已经写过一个类似的
01171015_stu:
<!DOCTYPE html PUBLIC \公众-//W3C//DTD XHTML 1.0 Transitional//EN\"大众 \"大众http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"大众><html xmlns=\"大众http://www.w3.org/1999/xhtml\"大众><head><meta http-equiv=\"大众Content-Type\公众 content=\"大众text/html; charset=utf-8\"大众 /><title>01171015_stu</title><style type=\"大众text/css\"大众>table{background-color:#333;}table td{background-color:#FF0;}</style></head><?php require './01171015_init.php'; ?><body><div class=\"大众green\"大众><form method=\"大众post\"大众 action=\公众01171015_opt?opt=add\"大众><table width=\公众482\"大众 cellspacing=\"大众1\"大众 align=\公众center\"大众><tr><td colspan=2 align=\公众center\"大众>填写学生信息</td></tr><tr><td width=\"大众86\"大众>名字</td><td width=\"大众387\"大众><input type=\公众text\"大众 name=\"大众stu_name\"大众/></td></tr><tr><td>学号</td><td><input type=\"大众text\"大众 name=\公众stu_id\"大众/></td></tr><tr><td>密码</td><td><input type=\"大众password\"大众 value=\公众123456\"大众 name=\"大众p1\"大众 id=\"大众stu_password\"大众/>默认密码:123456</td></tr><tr><td>角色</td><td><input type=\"大众text\公众 name=\"大众stu_role\公众/></td></tr><tr><td>性别</td><td><input type=\公众radio\公众 name=\"大众stu_gender\"大众 value=\"大众男\"大众/>男<input type=\"大众radio\"大众 name=\"大众stu_gender\"大众 value=\公众女\公众/>女<input type=\公众radio\公众 name=\"大众stu_gender\公众 value=\公众其他\"大众/>其他</td></tr><tr><td>出生年月</td><td><select name=\"大众year\"大众><?phpfor ( $i = 1990; $i <= 2020; $i++ ) {?><option value=\"大众<?php echo $i;?>\公众><?php echo $i;?></option><?php}?></select>年<select name=\"大众math\"大众><?phpfor ( $i = 1; $i <=12; $i++ ) {?><option value=\公众<?php echo $i;?>\"大众><?php echo $i;?></option><?php}?></select>月<input type=\公众text\"大众 name=\"大众day\"大众/>日</td></tr><tr><td>手机号码</td><td><input type=\"大众text\"大众 name=\"大众stu_phone\"大众/></td></tr><tr><td>班级</td><td><select name=\"大众class_id\"大众 ><option>物联1710</option><option>物联1709</option><option>物联1711</option><option>物联1712</option><option>物联1713</option><option>物联1714</option></select>班</td></tr><tr><td>爱好</td><td><input type=\"大众checkbox\"大众 name=\"大众stu_hobby[]\公众 value=\"大众刺激战场\"大众/>刺激战场<input type=\"大众checkbox\"大众 name=\公众stu_hobby[]\"大众 value=\"大众王者光彩\"大众/>王者光彩<input type=\"大众checkbox\公众 name=\"大众stu_hobby[]\"大众 value=\"大众LOL\"大众/>LOL<input type=\公众checkbox\"大众 name=\"大众stu_hobby[]\公众 value=\"大众今日头条\公众/>今日头条<input type=\公众checkbox\公众 name=\"大众stu_hobby[]\公众 value=\"大众其他\"大众/>其他</td></tr><tr><td colspan=2 align=\公众center\"大众><input type=\"大众submit\"大众 value=\公众提交\"大众/></td></tr></table></form><div></body></html>三、我们查看一下效果
1.运行01171015_list.php文件