功能描述:显示当日教师发布的所有作业
关键代码说明:
<table width="100%" border="0" >
<tr>
<td colspan="4"><hr></td>
</tr>
<%
int intPageSize;//每页显示的记录条数
int intRowCount;//总记录数
int intPageCount;//总页数
int intPage;//提交的页码
String strPage;//当前页码
int ii;
intPageSize=4;
strPage=request.getParameter("page");
if(strPage==null){
intPage=1;
}
else{
intPage=java.lang.Integer.parseInt(strPage);
if (intPage<1)intPage=1;
}
String sql1="select * from main where date='"+yearmonth+"' order by date desc";
rst=stmt.executeQuery(sql1);
rst.last();
intRowCount=rst.getRow();
intPageCount=(intRowCount+intPageSize-1)/intPageSize;//计算总页数
if (intPage>intPageCount) intPage=intPageCount;//提交的页数大于总页数
if(intPageCount>0){
rst.absolute((intPage-1)*intPageSize+1); //移动记录指针到待显示记录上
ii=0;
while (ii<intPageSize&&!rst.isAfterLast()){
%>
<tr>
<td height="20" colspan="4" bgcolor="#eaeaea">
<div align="left"><strong><a href="content.jsp?id=<%=rst.getString("mainid")%>">
<%=trans(rst.getString("title"))%></a></strong></div></td>
</tr>
<tr>
<td colspan="4" background="pics/dot_line.gif" height="1"></td>
</tr>
<tr><td colspan="4"><%
String co=rst.getString("content").toString();
int len=co.length();
if(len<100)
{
String content=co.substring(0,len);
out.print(trans(content));
out.print("……");
}else{
String content=co.substring(0,100);
out.print("……");
}
%></td></tr>
<tr>
<td colspan="4" background="pics/dot_line.gif" height="1"></td>
</tr>
<tr>
<td width="32%"><div align="right"><a href="content.jsp?id=<%=rst.getString("mainid")%>">
阅读全文</a> </div></td>
<td width="24%">作业类型:
<%
String typeid=rst.getString("typeid");
Connection con2=n.getConnection();
Statement stmt2=con2.createStatement();
String sql2="select * from type where typeid='"+typeid+"'";
ResultSet rst2=stmt2.executeQuery(sql2);
if(rst2.next()){
out.print(trans(rst2.getString("typename")));
}
rst2.close();
stmt2.close();
con2.close();
%>
</td>
<td width="19%">作者: <%
String id=rst.getString("teacherid");
Connection conn=n.getConnection();
Statement stmtt=conn.createStatement();
String Sql="select * from teacher where teacherid='"+id+"'";
ResultSet rstt=stmtt.executeQuery(Sql);
while(rstt.next()){
out.print(trans(rstt.getString("teachername")));
rstt.close();
stmtt.close();
conn.close();
%> </td>
<td width="25%">日期:<%=rst.getString("date").substring(0,10)%></td>
</tr>
<tr>
<td colspan="4" ><hr></td>
</tr>
<%
rst.next();
ii++;
}
}
%>
<tr>
<TD colspan="4"><form action="showdaywork.jsp" method="post">
<div align="right">第<%=intPage%>页 共<%=intPageCount%>页
<%if(intPage<intPageCount){%>
<a href="showdaywork.jsp?page=<%=intPage+1%>&yearmonth=<%=yearmonth%>">
下一页</a>
<%}%>
<%if(intPage>1){%>
<a href="showdaywork.jsp?page=<%=intPage-1%>&yearmonth=<%=yearmonth%>">上一页</a>
<%}%>
<a href="#" onClick="history.go(-1);">返回</a> </div>
</form></TD>
</tr>
</table>
posted on 2005-06-01 10:09
瘦猴 阅读(443)
评论(0) 编辑 收藏