Watch Star Fork

XiaoSK / DB2PHPGPL-2.0

加入码云
与超过 300 万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
DB2 是 2013-2014 学年春季学期数据库实验。
一键复制 编辑 原始数据 按行查看 历史
student.php 15.27 KB XiaoSK 提交于 2014-05-28 14:53 . Release
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
<?
require 'ctrl/conn.php';
if($_SESSION['class'] != '1') {
require 'logout.php';
exit();
}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>学生选课 - 上海大学选课系统</title>
<script type="text/javascript" src="static/jquery.min.js"></script>
<script type="text/javascript">
function msg(w, m){
var notify = window.webkitNotifications.createNotification('static/' + w + '.png', '提示信息', m);
//设置定时撤销机制,防止通知长时间显示不被关闭
notify.ondisplay = function(event) {
setTimeout(function() {
event.currentTarget.cancel();
}, 4444);
};
//下面是定义点击事件,类似地还可定义其它事件
notify.onclick = function() {
window.focus();
this.cancel();
};
//弹出
notify.show();
}
</script>
<link rel="stylesheet" href="static/pure-min.css" />
<link rel="stylesheet" href="static/mainframe.css" />
<style type="text/css">
#cstable th:nth-child(1),#cstable td:nth-child(1) {
width: 150px;
text-align: center;
}
#query input {
width: 270px!important;
}
#query button {
margin: 0 auto;
}
#jd tr td:nth-child(1), #jd tr td:nth-child(4),#jd tr td:nth-child(5),#jd tr td:nth-child(6) {
text-align: center;
}
#qqq th,#qqq td {
padding: 5px!important;
}
#dialog {
border: 4px solid #eee;
border-radius: 2px;
width: 900px;
position: fixed;
top:100px;
left:50%;
margin-left: -454px;
background: white;
display: none;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<?
$st = $dbc->prepare("SELECT xm,jd FROM student WHERE xh=?");
$st->bindValue(1, $_SESSION['id']);
$st->execute();
$xm = $st->fetchAll();
echo $_SESSION['id'].' '.$xm[0][0].' 上学期平均绩点:'.substr($xm[0][1],0,5);
?> | <a href="logout.php">安全退出</a>
</div>
<div class="func">
<a href="?func=courseinsert">选课</a>
<a href="?func=coursecancel">退课</a>
<a href="?func=coursetable">课表查询</a>
<a href="?func=courseselect">课程查询</a>
<a href="?func=coursedelete">删选记录</a>
<a href="?func=gradequery">成绩查询</a>
</div>
<div class="main">
<?
if(isset($_GET['func'])) {
if($_GET['func'] == 'coursetable') { // 课程查询
$ab = ord('A'); // 返回A的ASCII码值
$res = $dbc->prepare("SELECT courseteach.km,courseteach.bittime,courseteach.time,courseteach.room FROM grade,courseteach WHERE grade.id=courseteach.id AND grade.xh=?");
$res->bindValue(1,$_SESSION['id']);
$res->execute();
$rs = $res->fetchAll();
require 'ctrl/timeCalc.php';
for($xsk=0;$xsk<count($rs);$xsk++) {
// A 课名 时间 td下标数组 教室
$list[] = array(chr($ab++), $rs[$xsk][0], tm($rs[$xsk][1]), $rs[$xsk][2], $rs[$xsk][3]);
}
$l = json_encode($list);
?>
<table class="pure-table" style="margin-bottom:20px;text-align:center;">
<thead>
<tr>
<th>上课时间</th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody id="time">
<tr class="pure-table-odd">
<td>08:00 ~ 08:45</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>08:55 ~ 09:40</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr class="pure-table-odd">
<td>10:00 ~ 10:45</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>10:55 ~ 11:40</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr class="pure-table-odd">
<td>12:10 ~ 12:55</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>13:05 ~ 13:50</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr class="pure-table-odd">
<td>14:10 ~ 14:55</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>15:05 ~ 15:50</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr class="pure-table-odd">
<td>16:00 ~ 16:45</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>16:55 ~ 17:40</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr class="pure-table-odd">
<td>18:00 ~ 18:45</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>18:55 ~ 19:40</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr class="pure-table-odd">
<td>19:50 ~ 20:35</td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
<script type="text/javascript">
$(function (){
var deep = JSON.parse('<? echo $l; ?>'), sp="</td><td>", ls;
for(var i=0; i<deep.length;i++) {
// 对应表
ls = "<tr><td>" + deep[i][0];
ls += (sp + deep[i][1] + sp + deep[i][3] + sp + deep[i][4]);
ls += "</td></tr>"
$("#map").append(ls);
// 格表
for(var j=0;j<deep[i][2].length;j++) {
$("#time tr:eq(" + (deep[i][2][j]%13) +") td:eq(" + (parseInt(deep[i][2][j]/13)+1) + ")").html(deep[i][0]);
}
}
});
</script>
<table class="pure-table pure-table-bordered">
<thead>
<tr>
<th>编号</th>
<th>课程名</th>
<th>上课时间</th>
<th>上课地点</th>
</tr>
</thead>
<tbody id="map">
</tbody>
</table>
<?
} else if($_GET['func'] == 'courseinsert') { // 选课
?>
<script type="text/javascript">
function dynAddInput() {
var ia = '<input type="text" value name="kh[]" placeholder="课程号" maxlength="8"> <input type="text" value name="gh[]" placeholder="教师号" maxlength="8">   <input type="text" value name="kh[]" placeholder="课程号" maxlength="8"> <input type="text" value name="gh[]" placeholder="教师号" maxlength="8"><br><br>';
$("#xk fieldset").append(ia);
}
function enroll() {
var pairs = $("input").length, kk=0, cnt=0;
var serial="";
for(var ii=0; ii<pairs; ii+=2) {
if(ii > 0) {
serial += "&";
}
kk = ii + 1;
if( /^([0-9A-Z]{8})$/.test( $("input:eq(" + ii + ")").val() ) && /^([0-9A-Z]{8})$/.test( $("input:eq(" + kk + ")").val() ) ) {
serial += ( "kh[]=" + $("input:eq(" + ii + ")").val() + "&gh[]=" + $("input:eq(" + kk + ")").val() );
cnt++;
} else if( $("input:eq(" + ii + ")").val() == "" && $("input:eq(" + kk + ")").val() == ""){
console.log("□"); //哈哈
} else {
msg("e","数据格式非法,请修改!");
return;
}
}
if(cnt <= 0) {
msg("e","请填好再提交!");
return;
}
$.ajax({
type : "post",
url : "ctrl/stuEnrol.php",
data : serial,
async : false,
success : function(data){
if(data == "i" || data==" " || data=="") {
msg("e", "请求失败!");
} else if(data == "t") {
msg("i", "选课时间未到!");
} else {
var reply = JSON.parse(data), ls, sp = "</td><td>";
$("#result tr").remove();
for(var i=0; i<reply.length; i++) {
ls = "<tr><td>";
ls += (i + 1);
for(var j=0; j<6;j++) {
ls += (sp + reply[i][j]);
}
ls += "</td></tr>";
$("#result").append(ls);
}
$("#dialog").show(300);
}
}
});
}
</script>
<form class="pure-form" id="xk">
<fieldset>
<input type="text" value name="kh[]" placeholder="课程号" maxlength="8"> <input type="text" value name="gh[]" placeholder="教师号" maxlength="8">  
<input type="text" value name="kh[]" placeholder="课程号" maxlength="8"> <input type="text" value name="gh[]" placeholder="教师号" maxlength="8"><br><br>
</fieldset>
<center>
<button type="button" class="pure-button pure-button-primary" onclick="enroll();">选定</button> 
<button type="button" class="pure-button" onclick="dynAddInput();">添加更多课程项</button> 
<button type="reset" class="pure-button">重置</button>
</center>
</form>
<?
} else if($_GET['func'] == 'coursecancel') { // 退课
?>
<table class="pure-table pure-table-bordered" id="tkt">
<thead>
<tr>
<th>#</th>
<th>课程号</th>
<th>课程名</th>
<th>教师号</th>
<th>上课时间</th>
<th>学分</th>
</tr>
</thead>
<tbody>
<?
$css = $dbc->query("SELECT grade.id,courseteach.kh,courseteach.km,courseteach.gh,courseteach.time,courseteach.xf FROM grade,courseteach WHERE grade.id=courseteach.id AND grade.xh='".$_SESSION['id']."'");
foreach( $css as $row ) {
echo "<tr><td><input type='checkbox' name='tkid[]' value='$row[0]'></td>";
for($dty=1;$dty<=5;$dty++) {
echo "<td>".$row[$dty]."</td>";
}
echo '</tr>';
}
?>
</tbody>
</table>
<center>
<button type="button" class="pure-button pure-button-primary" style="margin:10px auto" onclick="tk();">退课</button>
</center>
<script type="text/javascript">
function tk() {
$.ajax({
type : "post",
url : "ctrl/stuEnrol.php",
data : $("input:checked").serialize(),
async : false,
success : function(data){
msg("i", data);
location.href = location.href;
}
});
}
</script>
<?
} else if($_GET['func'] == 'courseselect') { // 课程查询
?>
<form class="pure-form pure-form-stacked" id="query">
<fieldset>
<div class="pure-g">
<div class="pure-u-1-3">
<label for="kh">课程号:</label>
<input id="kh" type="text" name="kh" placeholder="课程号" maxlength="8">
</div>
<div class="pure-u-1-3">
<label for="km">课程名称:</label>
<input id="km" type="text" name="km" placeholder="课程名称">
</div>
<div class="pure-u-1-3">
<label for="gh">教师号:</label>
<input id="gh" type="text" name="gh" placeholder="教师号" maxlength="8">
</div>
<div class="pure-u-1-3">
<label for="xm">教师姓名:</label>
<input id="xm" type="text" name="xm" placeholder="教师姓名">
</div>
<div class="pure-u-1-3">
<label for="time">上课时间:</label>
<input id="time" type="text" name="time" placeholder="上课时间">
</div>
<div class="pure-u-1-3">
<label for="xf">学分数:</label>
<input id="xf" type="text" name="xf" placeholder="学分数">
</div>
<div class="pure-controls" style="margin:10px 340px;">
<button type="button" class="pure-button pure-button-primary" onclick="q();">模糊查询</button> 
<button type="reset" class="button-secondary pure-button">重置</button>
</div>
</div>
</fieldset>
</form>
<table class="pure-table pure-table-bordered" id="qqq" style="display:none;">
<thead>
<tr>
<th>#</th>
<th>课程号</th>
<th>课程名</th>
<th>教师号</th>
<th>教师名</th>
<th>上课时间</th>
<th>学分</th>
<th>人数</th>
</tr>
</thead>
<tbody id="qq">
</tbody>
</table>
<script type="text/javascript">
function q() {
$.ajax({
type : "post",
url : "ctrl/csSelect.php",
data : $("form#query").serialize(),
async : false,
success : function(data){
var arr = JSON.parse(data);
var len = arr.length, i, j, ls, sp = '</td><td>';
$("#qq tr").remove();
for(i=0;i<len;i++){
ls = "<tr><td><input type='checkbox' value='kh[]=" + arr[i][0];
ls += ("&gh[]=" + arr[i][2]);
ls += "&' name='chk[]' />";
for(j=0;j<7;j++) {
ls += (sp + arr[i][j]);
}
ls += ("/" + arr[i][j] + "</td></tr>");
$("#qq").append(ls);
}
$("#qqq").show();
$("#ff").show();
}
});
}
function i() {
var ser="";
for(var p=0;p<$("input[type=checkbox]:checked").length;p++){
ser += $("input[type=checkbox]:checked")[p].value;
}
if(ser=='') {
msg('i','请选择要选入的课程!');
return ;
}
$.ajax({
type : "post",
url : "ctrl/stuEnrol.php",
data : ser,
async : false,
success : function(data){
if(data == "i" || data==" " || data=="") {
msg("e", "请求失败!");
} else if(data == "t") {
msg("i", "选课时间未到!");
} else {
var reply = JSON.parse(data), ls, sp = "</td><td>";
$("#result tr").remove();
for(var i=0; i<reply.length; i++) {
ls = "<tr><td>";
ls += (i + 1);
for(var j=0; j<6;j++) {
ls += (sp + reply[i][j]);
}
ls += "</td></tr>";
$("#result").append(ls);
}
$("#dialog").show(300);
}
}
});
}
</script>
<div style="text-align:center;display:none;margin:10px 0;" id="ff">
<button class="pure-button pure-button-primary" onclick="i();">选入</button> 支持模糊查询,但最多仅显示50条。
</div>
<?
} else if($_GET['func'] == 'coursedelete') { // 删选记录
?>
<table class="pure-table">
<thead>
<tr>
<th>#</th>
<th>课程号</th>
<th>课程名</th>
<th>教师号</th>
<th>上课时间</th>
<th>学分</th>
</tr>
</thead>
<tbody>
<?
$css = $dbc->query("SELECT history.id,courseteach.kh,courseteach.km,courseteach.gh,courseteach.time,courseteach.xf FROM history,courseteach WHERE history.id=courseteach.id AND history.xh='".$_SESSION['id']."'");
$num = 1;
foreach( $css as $row ) {
echo "<tr><td>$num</td>";
$num++;
for($dty=1;$dty<=5;$dty++) {
echo "<td>".$row[$dty]."</td>";
}
echo '</tr>';
}
?>
</tbody>
</table>
<?
} else if($_GET['func'] == 'gradequery') { // 成绩查询
require 'ctrl/gpaCalc.php';
?>
<table class="pure-table pure-table-bordered">
<thead>
<tr>
<th>#</th>
<th>课程号</th>
<th>课程名</th>
<th>学分</th>
<th>成绩</th>
<th>绩点</th>
</tr>
</thead>
<tbody id="jd">
<?
$css = $dbc->query("SELECT courseteach.kh,courseteach.km,courseteach.xf,grade.zpcj FROM grade,courseteach WHERE grade.id=courseteach.id AND xh='".$_SESSION['id']."'");
$looper = 1;
foreach($css as $row) {
echo '<tr><td>'.$looper;
echo '</td><td>'.$row[0].'</td><td>'.$row[1].'</td><td>'.$row[2].'</td><td>'.($row[3]==''?'暂未公布':$row[3]).'</td><td>';
echo ($row[3]==''?'暂未公布':gpa($row[3],$dbc)).'</td></tr>';
$looper++;
}
?>
</tbody>
</table>
<?
}
} else { // 未进行功能选择,暂时显示本学期选课时间等信息
$st = $dbc->prepare("select v from admin where k=? limit 1");
$st->bindValue(1, 'xk1');
if($st->execute()) {
$rs = $st->fetchAll();
$rs = $rs[0][0];
$t1 = substr($rs, 0, 4).'-'.substr($rs, 4, 2).'-'.substr($rs, 6, 2).' '.substr($rs, 8,2).':'.substr($rs, 10,2)
.'至'.substr($rs, 13, 4).'-'.substr($rs, 17,2).'-'.substr($rs, 19,2).' '.substr($rs, 21,2).':'.substr($rs, 23);
}
$st->bindValue(1, 'xk2');
if($st->execute()) {
$rs = $st->fetchAll();
$rs = $rs[0][0];
$t2 = substr($rs, 0, 4).'-'.substr($rs, 4, 2).'-'.substr($rs, 6, 2).' '.substr($rs, 8,2).':'.substr($rs, 10,2)
.'至'.substr($rs, 13, 4).'-'.substr($rs, 17,2).'-'.substr($rs, 19,2).' '.substr($rs, 21,2).':'.substr($rs, 23);
}
?>
<div class="terminfo">
<h1>欢迎您使用选课系统!</h1>
<h3>一轮选课时间:<?=$t1?></h3>
<h3>二轮选课时间:<?=$t2?></h3>
<h3>如遇问题请联系:66133370</h3>
</div>
<?
}
?>
</div>
</div>
<div id="dialog">
<table class="pure-table pure-table-bordered" width="100%">
<thead>
<tr style="text-align:center;">
<th>#</th>
<th>课程号</th>
<th>课程名</th>
<th>教师号</th>
<th>学分</th>
<th>上课时间</th>
<th>结果</th>
</tr>
</thead>
<tbody id="result">
</tbody>
</table>
<center>
<button type="button" class="pure-button pure-button-primary" style="margin:10px auto" onclick="$('#dialog').hide(444);">关闭</button>
</center>
</div>
</body>
</html>

评论 ( 0 )

你可以在登录后,发表评论

11_float_left_people 11_float_left_close