xuanxiuke2.jsp~6~
上传用户:top0756
上传日期:2022-08-11
资源大小:6501k
文件大小:3k
源码类别:

Jsp/Servlet

开发平台:

VBScript

  1. <%@ page contentType="text/html; charset=GBK" %>
  2. <%@ page import="java.sql.*" %>
  3. <%@ page language="java" %>
  4. <%@ page import="java.util.*" %>
  5. <%@ page import="proj112.*" %>
  6. <jsp:useBean id="a" scope="page" class="proj112.dbconn"/>
  7. <html>
  8. <head>
  9. <title>
  10. xuanke_1
  11. </title>
  12. </head>
  13. <body bgcolor="#ffffff">
  14.    <%
  15.        String kechenghao=request.getParameter("kechenghao");
  16.        int totalrecord = 0;
  17.        String sql="";
  18.        String sql1="";
  19.        String sql2="";
  20.        String name="";
  21.        sql="SELECT * FROM kecheng where kch='"+kechenghao+"'";
  22.        ResultSet rs=a.executeQuery(sql);
  23.  if(rs.next())
  24.    {
  25.      name=rs.getString("kcm");
  26.      %>
  27.      <br> 课程号:<%=kechenghao %>&nbsp;&nbsp; 课程名:<%=name %>,选修该课程的学生如下:<br><br><hr><br><br>
  28.      <%  sql1 = "SELECT count(*) as recordcount FROM 选课关联 where kch='"+kechenghao+"'";
  29.      ResultSet bs = a.executeQuery(sql1);
  30.      if (bs.next())
  31.      {
  32.        totalrecord = bs.getInt("recordcount");
  33.        if(totalrecord!=0){
  34.          sql2="SELECT * FROM 选课关联,student where 选课关联.stu_id=student.stu_id and 选课关联.kch='"+kechenghao+"'";
  35.          ResultSet ts=a.executeQuery(sql2);
  36.          %>
  37.          <p align="center">
  38.            <table width="500" cellpadding=3 cellspacing=0 align=center border=1 bordercolor="#FFCCCC" >
  39.              <tr>
  40.                <td align="center"><font color="#6633CC">姓名</font></td>
  41.                <td align="center"><font color="#6633CC">学号</font></td>
  42.                <td align="center"><font color="#6633CC">性别</font></td>
  43.                <td align="center"><font color="#6633CC">专业</font></td>
  44.                <td align="center"><font color="#6633CC">民族</font></td>
  45.                <td align="center"><font color="#6633CC">政治面貌</font></td>
  46.              </tr>
  47.              <%
  48.              while(ts.next()){%>
  49.              <tr>
  50.                <td align="center"><%=ts.getString(4)%></td>
  51.                <td align="center"><%=ts.getString(5)%></td>
  52.                <td align="center"><%=ts.getString(7)%></td>
  53.                <td align="center"><%=ts.getString(8)%></td>
  54.                <td align="center"><%=ts.getString(9)%></td>
  55.                <td align="center"><%=ts.getString(10)%></td>
  56.              </tr>
  57.              <%} %>
  58.            </table><br ><hr><br>
  59.          <center>
  60.            选修该课程的人数为:&nbsp;&nbsp;<input type="text" value="<%=totalrecord%>" size="2" align="right" readonly="readonly">&nbsp;人
  61.          </center>
  62.            <%}else
  63.            {%>
  64.            <script language="javascript">
  65.            alert("没有选修这门课程的学生");
  66.            history.go(-1);
  67.            history.go(0);
  68.            </script>
  69.            <%}
  70.            }else
  71.            {%>
  72.            <script language="javascript">
  73.            alert("没有选修这门课程的学生");
  74.            history.go(-1);
  75.            history.go(0);
  76.            </script>
  77.            <%}
  78.            }
  79.    else
  80.      {%>
  81.      <script language="javascript">
  82.      alert("没有你输入的课程号,请重新输入");
  83.      history.go(-1);
  84.      history.go(0);
  85.      </script>
  86.    <%}
  87.       %>
  88. </body>
  89. </html>