?? student_noticelist.jsp
字號:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</title>
<style type="text/css">
<!--
.STYLE3 {color: #0000FF; }
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:1;
left: 16px;
top: 20px;
}
#Layer2 {
position:absolute;
width:306px;
height:250px;
z-index:1;
left: 31px;
top: 33px;
}
#Layer3 {
position:absolute;
width:110px;
height:251px;
z-index:2;
left: 334px;
top: 33px;
}
#Layer4 {
position:absolute;
width:593px;
height:251px;
z-index:3;
left: 441px;
top: 33px;
}
-->
</style>
</head>
<body>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String driver = "jdbc:odbc:netteach";
//如果是采用windwos驗證方式,則采用下面的語句連接
//Connection conn = DriverManager.getConnection(driver);
//如果采用SQL Server驗證方式,則采用下面語句,其中sa是用戶名,密碼為空,如果用戶設置了密碼,后面的引號中寫入密碼
Connection conn = DriverManager.getConnection(driver);
Statement stmt = conn.createStatement();
String uid=(String)session.getAttribute("user_id");
String sql="select * from n_record , n_notice ,n_user, n_course where n_record.user_id='"+uid+"'and n_record.course_id=n_notice.course_id and n_record.course_id=n_course.course_id and n_course.user_id=n_user.user_id";
%>
<div id="Layer2">
<table width="307" border="1" cellpadding="0" cellspacing="0" bordercolor="#DDF2F8">
<tr>
<td width="90" height="34" class="STYLE3"><div align="center">課程ID</div></td>
<td width="100" class="STYLE3"><div align="center">課程名稱</div></td>
<td width="109" class="STYLE3"><div align="center">開課學院</div></td>
</tr></table>
<%//rs為返回結果的ResultSet對象
ResultSet rs=stmt.executeQuery(sql);
while(rs.next())
{
String courseid=(String)rs.getString(3);
String coursename=(String)rs.getString(13);
String college=(String)rs.getString(14);
%><tr>
<table width="307" border="1" cellpadding="0" cellspacing="0" bordercolor="#DDF2F8">
<td width="90" height="34"><div align="center" class="STYLE3"><%=courseid%></div></td>
<td width="100"><div align="center" class="STYLE3"><%=coursename%></div></td>
<td width="109"><div align="center" class="STYLE3"><%=college%></div></td>
</table>
</tr>
<%
}
rs.close();
%>
</div>
<div id="Layer3">
<table width="110" border="1" cellpadding="0" cellspacing="0" bordercolor="#DDF2F8">
<tr>
<td width="110" height="34"><div align="center" class="STYLE3">授課教員</div></td>
</tr>
</table>
<%//rs2為返回結果的ResultSet對象
ResultSet rs2=stmt.executeQuery(sql);
while(rs2.next())
{
String teachername=(String)rs2.getString(11);
%>
<tr>
<table width="110" border="1" cellpadding="0" cellspacing="0" bordercolor="#DDF2F8">
<td width="110" height="34"><div align="center" class="STYLE3"><%=teachername%></div></td>
</table>
</tr>
<%
}
rs2.close();
%>
</div>
<div id="Layer4">
<table width="590" border="1" cellpadding="0" cellspacing="0" bordercolor="#DDF2F8">
<tr>
<td width="450" height="34" class="STYLE3"><div align="center">課程公告</div></td>
<td width="140" height="34" class="STYLE3"><div align="center">公告日期</div></td>
</tr>
</table>
<%//rs3為返回結果的ResultSet對象
ResultSet rs3=stmt.executeQuery(sql);
while(rs3.next())
{
String noticedetail=(String)rs3.getString(4);
String noticedate=(String)rs3.getString(5);
%>
<tr>
<table width="590" border="1" cellpadding="0" cellspacing="0" bordercolor="#DDF2F8">
<td width="450" height="34"><div align="center" class="STYLE3"><%=noticedetail%></div></td>
<td width="140" height="34"><div align="center" class="STYLE3"><%=noticedate%></div></td>
</table>
</tr>
<%
}
rs3.close();%>
</div>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -