注册 登录
编程论坛 ASP技术论坛

选课系统已选人数

jessicecat 发布于 2010-09-14 10:02, 530 次点击
选课系统里面学生选择了某一门课程以后,那一门课程应该显示已经有一人选择了该门课程,但是已选人数显示仍为0.
已选人数的字段为“yxrs”,
想出来这样的效果:如果某个学生已经选了课程,就弹出你已经选课了,直接进入到"wdkc"这个页面,
<%
call CheckLogin()'一般用户访问权限判断函数
'Response.Write(Request("kcid"))
'Response.End()

Set rs = Server.CreateObject("adodb.recordset")
rs.open "Select * from 学生表_student where name = '"&Session("XZW_xsID")&"'",conn,1,1
if rs("SXKC") <> "" then
Response.Write("<script>alert('你已经选过课了!');window.location='wdkc.asp';</script>")
else

Call chkt()

rs.open "Select * from 学生表_student where name = '"&Session("XZW_xsID")&"'",conn,1,3
rs("SXKC") = Request("kcid")
    rs("yxrs")=rs("yxrs")+1
               
               
            
rs.update
rs.close
Response.Write("<script>alert('选课成功!');window.location='xuanke.asp';</script>")

End If


Function chkt()
kc = Split(Request("kcid"),",")
for i = 0 to Ubound(kc)

Set rs = Server.CreateObject("adodb.recordset")
rs.open "Select * from 教师表_teacher where id = "&kc(i),conn,1,1
kcname = rs("kcmc")
if rs("xzrs") = rs("kcxf") then Response.Write("<script>alert('"&kcname&"已经满了!');window.location='xuanke.asp';</script>") end if
rs.close
next
End Function
%>
3 回复
#2
hams2010-09-14 11:30
不如
建个选课字段
谁选了就记录他的姓名或学号
要查某个课有多少人选,就查有几条记录
要查某个学生选了什么课,就查他的姓名或学号的选课记录
#3
jessicecat2010-09-14 12:12
回复 2楼 hams
"SXKC"就是所选课程的字段
#4
jessicecat2010-09-14 12:16
回复 2楼 hams
这个是选课的保存页面,每个学生是单独登录选课然后可以显示他个人所选的课程
1