-
Notifications
You must be signed in to change notification settings - Fork 2
/
Students.php
86 lines (78 loc) · 1.77 KB
/
Students.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* Created by PhpStorm.
* User: starz
* Date: 2017/6/15
* Time: 16:54
*/
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>学生信息</title>
<?php
session_start();
include "DbCon.php";
?>
<script>
function dodel(stuid) {
var res = confirm('确认删除?')
if(res) {
window.location='DbCon.php?action=del&id='+stuid;
}
}
</script>
</head>
<body>
<p align="right">
<?php
if ($_SESSION['admin'] == 1)
echo "管理员 ".$_SESSION['user'];
else
echo "学生 ".$_SESSION['user'];
?>
<a href="Logout.php"> 注销</a>
</p>
<?php if ($_SESSION['admin'] == 1){?>
<h3>管理学生信息</h3>
<?php }else{?>
<h3>浏览学生信息</h3>
<?php }?>
<table width="500" border="0">
<tr>
<th> ID </th>
<th> 姓名 </th>
<th>性别</th>
<th> 出生日期 </th>
<th> 专业 </th>
<?php if ($_SESSION['admin'] == 1){?>
<th> 操作 </th>
<?php }?>
</tr>
<?php
foreach ($rows as $row) {
echo "<tr>";
for ($num = 0; $num < 5; $num++) {
echo "<th>".$row[$num];
// echo " ".strlen($row[$num])." "; . " "
if ($num == 1&& strlen($row[1])/3 < 3){
echo " ";
}
echo "</th>";
}
if ($_SESSION['admin'] == 1){?>
<td>
<a href="Edit.php?id=<?php echo $row['id']?>"> 修改</a>
<a href="javascript:void(0);" onclick="dodel(<?php echo $row['0']?>)"> 删除</a>
</td>
<?php
}
echo "</tr>";
}
if ($_SESSION['admin'] == 1){
?>
<button onclick="{location.href='Insert.php'}">添加</button>
<?php }?>
</table>
</body>
</html>