- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章php实现学生管理系统由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
本文实例为大家分享了php学生管理系统源码,供大家参考,具体内容如下 。
功能:
1.添加/删除/修改 2.数据存储. 。
界面分布:
index.php --->主界面 add.php --->stu添加 action ---> sql中add/del/update (处理html表单-->mysql的数据存储 && 页面跳转) edit.php --->stu修改 menu.php -->首页 。
1. index.php 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>学生信息管理</
title
>
<
script
>
function doDel(id) {
if(confirm('确认删除?')) {
window.location='action.php?action=del&id='+id;
}
}
</
script
>
</
head
>
<
body
>
<
center
>
<?
php
include ("menu.php");
?>
<
h3
>浏览学生信息</
h3
>
<
table
width
=
"500"
border
=
"1"
>
<
tr
>
<
th
>ID</
th
>
<
th
>姓名</
th
>
<
th
>性别</
th
>
<
th
>年龄</
th
>
<
th
>班级</
th
>
<
th
>操作</
th
>
</
tr
>
<?
php
// 1. 链接数据库
try{
$
pdo
=
new
PDO("uri:mysqlPdo.ini","root","1");
}catch (PDOException $e) {
die('connection failed'.$e->getMessage());
}
//2.执行sql
$sql_select = "select * from stu";
//3.data 解析
foreach ( $pdo->query($sql_select) as $row) {
echo "<
tr
>";
echo "<
th
>{$row['id']} </
th
>";
echo "<
th
>{$row['name']}</
th
>";
echo "<
th
>{$row['sex']} </
th
>";
echo "<
th
>{$row['age']} </
th
>";
echo "<
th
>{$row['classid']}</
th
>";
echo "<
td
>
<
a
href
=
'edit.php?id={$row['
id']}'>修改</
a
>
<
a
href
=
'javascript:void(0);'
onclick
=
'doDel({$row['
id']})'>删除</
a
>
</
td
>";
echo "</
tr
>";
}
?>
</
table
>
</
center
>
</
body
>
</
html
>
|
2. add.php 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>学生管理系统</
title
>
</
head
>
<
body
>
<
center
>
<?
php
include ('menu.php'); ?>
<
h3
>增加学生信息</
h3
>
<
form
action
=
"action.php?action=add"
method
=
"post"
>
<
table
>
<
tr
>
<
td
>姓名</
td
>
<
td
><
input
type
=
"text"
name
=
"name"
></
td
>
</
tr
>
<
tr
>
<
td
>年龄</
td
>
<
td
><
input
type
=
"text"
name
=
"age"
></
td
>
</
tr
>
<
tr
>
<
td
>性别</
td
>
<
td
><
input
type
=
"radio"
name
=
"sex"
value
=
"男"
>男</
td
>
<
td
><
input
type
=
"radio"
name
=
"sex"
value
=
"女"
>女</
td
>
</
tr
>
<
tr
>
<
td
>班级</
td
>
<
td
><
input
type
=
"text"
name
=
"classid"
></
td
>
</
tr
>
<
tr
>
<!-- <td> </td>-->
<
td
><
a
href
=
"index.php"
>返回</
td
>
<
td
><
input
type
=
"submit"
value
=
"添加"
></
td
>
<
td
><
input
type
=
"reset"
value
=
"重置"
></
td
>
</
tr
>
</
table
>
</
form
>
</
center
>
</
body
>
</
html
>
|
3. action.php 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<?php
/**
* Created by PhpStorm.
* User: hyh
* Date: 16-7-7
* Time: 下午9:37
*/
//1. 链接数据库
try
{
$pdo
=
new
PDO(
"uri:mysqlPdo.ini"
,
"root"
,
"1"
);
}
catch
(PDOException
$e
) {
// echo 'Connection failed: ' . $e->getMessage();
die
(
'connection failed'
.
$e
->getMessage());
}
//2.action 的值做对操作
switch
(
$_GET
[
'action'
]){
case
'add'
:
//add
$name
=
$_POST
[
'name'
];
$sex
=
$_POST
[
'sex'
];
$age
=
$_POST
[
'age'
];
$classid
=
$_POST
[
'classid'
];
$sql
=
"insert into stu (name, sex, age, classid) values ('{$name}', '{$sex}','{$age}','{$classid}')"
;
$rw
=
$pdo
->
exec
(
$sql
);
if
(
$rw
> 0){
echo
"<script>alter('添加成功');</script>"
;
}
else
{
echo
"<script>alter('添加失败');</script>"
;
}
header(
'Location: index.php'
);
break
;
case
'del'
:
//get
$id
=
$_GET
[
'id'
];
$sql
=
"delete from stu where id={$id}"
;
$rw
=
$pdo
->
exec
(
$sql
);
if
(
$rw
> 0){
echo
"<script>alter('删除成功');</script>"
;
}
else
{
echo
"<script>alter('删除失败');</script>"
;
}
header(
'Location: index.php'
);
break
;
case
'edit'
:
//post
$id
=
$_POST
[
'id'
];
$name
=
$_POST
[
'name'
];
$age
=
$_POST
[
'age'
];
$classid
=
$_POST
[
'classid'
];
$sex
=
$_POST
[
'sex'
];
// echo $id, $age, $age, $name;
$sql
=
"update stu set name='{$name}', age={$age},sex='{$sex}',classid={$classid} where id={$id};"
;
// $sql = "update myapp.stu set name='jike',sex='女', age=24,classid=44 where id=17";
print
$sql
;
$rw
=
$pdo
->
exec
(
$sql
);
if
(
$rw
> 0){
echo
"<script>alter('更新成功');</script>"
;
}
else
{
echo
"<script>alter('更新失败');</script>"
;
}
header(
'Location: index.php'
);
break
;
default
:
header(
'Location: index.php'
);
break
;
}
|
4.edit.php 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>学生管理系统</
title
>
</
head
>
<
body
>
<
center
>
<?
php
include ('menu.php');
//1. 链接数据库
try{
$
pdo
=
new
PDO("uri:mysqlPdo.ini","root","1");
}catch (PDOException $e) {
die('connection failed'.$e->getMessage());
}
//2.执行sql
$sql_select = "select * from stu where id={$_GET['id']}";
$stmt = $pdo->query($sql_select);
if ($stmt->rowCount() >0) {
$stu = $stmt->fetch(PDO::FETCH_ASSOC); // 解析数据
}else{
die("no have this id:{$_GET['id']}");
}
?>
<
h3
>修改学生信息</
h3
>
<
form
action
=
"action.php?action=edit"
method
=
"post"
>
<
input
type
=
"hidden"
name
=
"id"
value="<?php echo $stu['id'];?>">
<
table
>
<
tr
>
<
td
>姓名</
td
>
<
td
><
input
type
=
"text"
name
=
"name"
value="<?php echo $stu['name'];?>"></
td
>
</
tr
>
<
tr
>
<
td
>年龄</
td
>
<
td
><
input
type
=
"text"
name
=
"age"
value="<?php echo $stu['age'];?>"></
td
>
</
tr
>
<
tr
>
<
td
>性别</
td
>
<
td
>
<
input
type
=
"radio"
name
=
"sex"
value
=
"男"
<?php echo ($stu['sex'] == "男")? "checked":"";?> >男
</
td
>
<
td
>
<
input
type
=
"radio"
name
=
"sex"
value
=
"女"
<?php echo ($stu['sex'] == "女")? "checked":"";?> >女
</
td
>
</
tr
>
<
tr
>
<
td
>班级</
td
>
<
td
><
input
type
=
"text"
name
=
"classid"
value="<?php echo $stu['classid']?>"></
td
>
</
tr
>
<
tr
>
<
td
> </
td
>
<
td
><
input
type
=
"submit"
value
=
"更新"
></
td
>
<
td
><
input
type
=
"reset"
value
=
"重置"
></
td
>
</
tr
>
</
table
>
</
form
>
</
center
>
<?
php
?>
</
body
>
</
html
>
|
5. menu.php 。
1
2
3
4
5
6
7
8
9
|
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
body
>
<
h2
>学生管理系统</
h2
>
<
a
href
=
"index.php"
> 浏览学生</
a
>
<
a
href
=
"add.php"
> 添加学生</
a
>
<
hr
>
</
body
>
</
html
>
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.
最后此篇关于php实现学生管理系统的文章就讲到这里了,如果你想了解更多关于php实现学生管理系统的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我们正在开发一个项目,该项目本身就是 CMS 系统,需要处理大量数字数据,如图像、视频和其他 Assets 。我们正在分析使用用 Java 构建的任何第三方 DAMS 系统的选项,因为我们在同一平台上
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
就目前情况而言,这个问题不太适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、民意调查或扩展讨论。如果您觉得这个问题可以改进并可能重新开放,visit
一个简单的问题。 在 magento 中,当转到 System/Configuration 时,左侧导航中有一些主要选项卡。 一般、目录、客户、销售、高级等。 我想知道什么 xml 为那些设置了顺序?
在开发过程中我发现系统配置->设计 HTML Head 部分丢失。 我已经阅读了很多教程,但没有得到这个问题的解决方案。 我已清除缓存并执行索引。 禁用所有安装模块。 我使用的是magento 1.7
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 5 年前。 Improve this qu
上下文 我正在遵循 GCP 对 Storing Secrets 的说明在存储桶中。 KMS 用于 file encryption在上传到存储桶之前。 由于数据加密发生在 Google 存储之外,我对
我目前正在为 KMS( key 管理服务)编写云形成模板(CFT),我想向 root 以外的用户授予 key 管理权限和 key 使用权限。我希望通过 CFT 动态调用它。到目前为止,我可以授予 ro
我是一名优秀的程序员,十分优秀!