1 Star 0 Fork 3

MyWZJ/基于php的学生成绩管理系统(后台)

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
studentedit.php 4.61 KB
一键复制 编辑 原始数据 按行查看 历史
友人A 提交于 2023-04-09 10:12 . 已完成
<?php
include_once('config/config.php');
$LoginAdmin = auth();
// 查询部门
$DepSql = "SELECT * FROM `stu_department`";
$DepData = all($DepSql);
if (!empty($_GET['id'])) {
$id = $_GET['id'];
$sql = "SELECT * FROM `stu_student` WHERE `id` = $id";
$Data = find($sql);
}
if ($_POST) {
// 判断action是否存在
$action = isset($_POST['action']) ? $_POST['action'] : '';
if($action == 'dep')
{
$DepSql = "SELECT * FROM `stu_department`";
$DepData = all($DepSql);
if($DepData)
{
success('查询成功',$DepData);
}else{
error('暂无数据');
}
}
// 封装数据
$data = [
'name' => $_POST['name'],
'age' => $_POST['age'],
'sex' => $_POST['sex'],
'depid' => $_POST['depid'],
];
$parents_phone = !empty($_POST['parents_phone']) ? $_POST['parents_phone'] : '';
if(strlen($_POST['parents_phone']) != 11)
{
ShowMsg('手机号是11位');
}
$data['parents_phone'] = $parents_phone;
$result = update('student',$data,"`id` = '$id'");
if($result)
{
ShowMsg('修改成功','studentlist.php');
}else{
ShowMsg('修改失败');
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php include_once('common/meta.php') ?>
</head>
<!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie ie7 "> <![endif]-->
<!--[if IE 8 ]> <body class="ie ie8 "> <![endif]-->
<!--[if IE 9 ]> <body class="ie ie9 "> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<style>
input[type="file"] {
display: none;
}
label[for="avatar"] {
width: 200px;
}
</style>
<body>
<!--<![endif]-->
<?php include_once('common/header.php') ?>
<?php include_once('common/nav.php') ?>
<div class="content">
<div class="header">
<h1 class="page-title">编辑学生</h1>
</div>
<ul class="breadcrumb">
<li><a href="index.php">Home</a> <span class="divider">/</span></li>
<li><a href="studentlist.php">StudentList</a> <span class="divider">/</span></li>
<li class="active">StudentEdit</li>
</ul>
<div class="container-fluid">
<div class="row-fluid">
<div class="btn-toolbar">
<button class="btn btn-primary" onClick="location='studentlist.php'"><i class="icon-list"></i> 学生列表</button>
<div class="btn-group">
</div>
</div>
<div class="well">
<div id="myTabContent" class="tab-content">
<div class="tab-pane active in" id="home">
<form method="post" enctype="multipart/form-data">
<label>学生姓名</label>
<input type="text" name="name" value="<?php echo $Data['name'] ?>" class="input-xxlarge" placeholder="请输入学生姓名">
<label>年龄</label>
<input type="number" name="age" value="<?php echo $Data['age'] ?>" class="input-xxlarge" placeholder="请输入年龄">
<label>家长电话</label>
<input type="tel" name="parents_phone" value="<?php echo $Data['parents_phone'] ?>" class="input-xxlarge" placeholder="请输入家长电话">
<label>性别</label>
<select name="sex" class="input-xlarge">
<option value="1" <?php echo $Data['sex'] == 1 ? 'selected' : '' ?>></option>
<option value="2" <?php echo $Data['sex'] == 2 ? 'selected' : '' ?>></option>
</select>
<label>所属部门</label>
<select name="depid" id="depid" class="input-xlarge">
<option value="0">请选择</option>
<?php foreach($DepData as $item) {?>
<option value="<?php echo $item['id'] ?>" <?php echo $Data['depid'] == $item['id'] ? 'selected' : '' ?>><?php echo $item['name'] ?></option>
<?php }?>
</select>
<label></label>
<input class="btn btn-primary" type="submit" value="提交" />
</form>
</div>
</div>
</div>
<?php include_once('common/footer.php') ?>
</div>
</div>
</div>
</body>
</html>
<?php include_once('common/script.php') ?>
<script>
// // 部门
// $.ajax({
// type:'post',
// url:'studentadd.php',
// data:{
// action:'dep'
// },
// dataType:'json',
// success:function(res)
// {
// if(res.code === 1)
// {
// var option = "<option value='0'>请选择</option>"
// for(var item of res.data)
// {
// option += `<option value="${item.id}">${item.name}</option>`
// }
// $('#depid').html(option)
// }
// }
// })
</script>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/mywzj/phpstudent.git
git@gitee.com:mywzj/phpstudent.git
mywzj
phpstudent
基于php的学生成绩管理系统(后台)
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385