一、功能
前台功能:
1、学生信息查看
2、学生信息添加
3、学生信息修改
4、学生信息删除
二、工具
PHP编程: Sublime Text、phpstorm…
SQL: mysql
环境搭建: PHP study(PHP 5.5 + Apache)
三、效果展示
网站首页:
添加学生信息:
修改学生信息:
删除学生信息:
查找学生信息:
四、网站核心代码示例
update_userpass.php 文件为例:
(采用的PDO预编译方法编写)
<?php
header("content-Type:text/html;charset=utf-8;");
//连接数据库
include 'conn.php';
$sql = "select * from student";
$date = $pdo->query($sql);
?>
<html>
<head>
<meta charset="UTF-8">
<title>学生信息管理系统</title>
</head>
<style type="text/css">
body {
background-image: url(student.jpg);
background-size: 100%;
}
.wrapper {
width: 1000px;
margin: 20px auto;
}
h1 {
text-align: center;
}
.add {
margin-bottom: 20px;
}
.add a {
text-decoration: none;
color: #fff;
background-color: #00CCFF;
padding: 6px;
border-radius: 5px;
}
td {
text-align: center;
}
</style>
<body>
<div class="wrapper">
<h1>学生信息管理系统</h1>
<div class="add">
<a href="addStudent.html">添加学生</a>
<a href="searchStudent.html">查找学生</a>
</div>
<table width="960" border="1">
<tr>
<th>编号</th>
<th>姓名</th>
<th>性别</th>
<th>年龄</th>
<th>学历</th>
<th>工资</th>
<th>奖金</th>
<th>籍贯</th>
<th>操作</th>
</tr>
<?php
foreach ($date as $key => $arr){
echo "<tr>";
echo "<td>{$arr['id']}</td>";
echo "<td>{$arr['name']}</td>";
echo "<td>{$arr['sex']}</td>";
echo "<td>{$arr['age']}</td>";
echo "<td>{$arr['edu']}</td>";
echo "<td>{$arr['salary']}</td>";
echo "<td>{$arr['bonus']}</td>";
echo "<td>{$arr['city']}</td>";
echo "<td>
<a href='javascript:del({$arr['id']})'>删除</a>
<a href='editStudent.php?id={$arr['id']}'>修改</a>
</td>";
echo "</tr>";
// echo "<pre>";
// print_r($arr);
// echo "</pre>";
}
?>
</table>
</div>
<script type="text/javascript">
function del(id) {
if (confirm("确定删除这个学生吗?")) {
window.location = "action_del.php?id=" + id;
}
}
</script>
</body>
</html>
网站代码结构: