<%
HttpSession httpSession = request.getSession();
// String tea_id= (String) httpSession.getAttribute("id_");
String tea_id=request.getParameter("id_");
Thesql thesql = new Thesql();
request.setCharacterEncoding("UTF-8");
String les="";//课程名称
String pu="";
String stu="";//是否审批
les=request.getParameter("les");
stu=request.getParameter("stu");
Pd_lesson pd[] = thesql.lesson_DimQuery("",les,pu,stu);
int itemsPerPage = 5;//每页展示多少条
int totalItems = pd.length;//总共多少条
int currentPage = request.getParameter("page") == null ? 1 : Integer.parseInt(request.getParameter("page"));
int totalPages = (int) Math.ceil(totalItems / (double)itemsPerPage);
int startItem = (currentPage - 1) * itemsPerPage + 1;
int endItem = Math.min(startItem + itemsPerPage - 1, totalItems);
%>
<body>
<h1>浏览课程</h1>
<table>
<tr>
<form action="Browse_lesson.jsp" method="post">
<th>编号</th>
<th>课程:<input type="text" name="les"></th>
<th>审批状态:<input type="text" name="stu"></th>
<th>发布作业</th>
<th>发布实验</th>
<th><input class="submit" type="submit"></th>
</form>
</tr>
<% for (int i = startItem; i < endItem; i++) { %>
<tr>
<td><%=pd[i].getId()%></td>
<td><%=pd[i].getLesson_name()%></td>
<td><%=pd[i].getIsPass()%></td>
<td>
<%if(pd[i].getIsPass().equals("已通过")&&tea_id.length()!=8) {%>
<a href="Publish_work.jsp?les_id=<%=pd[i].getId()%>&id_=<%=tea_id%>">发布作业</a>
<%}%>
</td>
<td>
<%if(pd[i].getIsPass().equals("已通过")&&tea_id.length()!=8) {%>
<a href="Publish_experiment.jsp?les_id=<%=pd[i].getId()%>&id_=<%=tea_id%>">发布实验</a>
<%}%>
</td>
<td><a href="look_lesson.jsp?les_id=<%=pd[i].getId()%>&id_=<%=tea_id%>">查看</a></td>
</tr>
<% }%>
</table>
<br>
<%
if(!(les!=null)) les="";
if(!(pu!=null)) pu="";
if(!(stu!=null)) stu="";
if(!(tea_id!=null)) tea_id="";
%>
<div id="pagination">
<%-- 显示翻页链接 --%>
<%-- &les=<%=les%>&pu=<%=pu%>&stu=<%=stu%>--%>
<a href="?page=<%= Math.max(1, currentPage - 1) %>&les=<%=les%>&pu=<%=pu%>&stu=<%=stu%>&id_=<%=tea_id%>" <%= currentPage == 1 ? "class=\"disabled page-link\"" : "class=\"page-link\"" %> >« 上一页</a>
<% for (int i = 1; i <= totalPages; i++) { %>
<a href="?page=<%= i %>&les=<%=les%>&pu=<%=pu%>&stu=<%=stu%>&id_=<%=tea_id%>" <%= i == currentPage ? "class=\"active\"" : "class=\"page-link\"" %> ><%= i %></a>
<% } %>
<a href="?page=<%= Math.min(currentPage + 1, totalPages) %>&les=<%=les%>&pu=<%=pu%>&stu=<%=stu%>&id_=<%=tea_id%>" <%= currentPage == totalPages ? "class=\"disabled page-link\"" : "class=\"page-link\"" %> >下一页 »</a>
</div>
</body>>
</html>