ASP读取数据分页问题
程序代码:
<% set conn=server.createobject("adodb.connection") conn.open("DRIVER=Driver do Microsoft Access (*.mdb);UID=admin;pwd=;dbq="&server.mappath("xkxt.mdb")) set rs=server.createobject("adodb.recordset") sql="select * from kcfl ORDER BY KCLBID ASC" rs.open sql,conn,3 rs.pagesize=20 if request("page")<>"" then epage=cint(request("page")) if epage<1 then epage=1 if epage>rs.pagecount then epage=rs.pagecount else epage=1 end if rs.absolutepage=epage %> <% for i=0 to rs.pagesize-1 if rs.bof or rs.eof then exit for %> <% rs.movenext() next %> <TABLE cellSpacing=1 borderColorDark=#ffffff cellPadding=0 width="98%" bgColor=#000000 borderColorLight=#000000 border=0> <TBODY> <TR bgColor=#f0f0f0 height=32> <TD align=middle>学院专业</TD> <TD align=middle>课程<BR> 编号</TD> <TD align=middle>课程名称</TD> <TD align=middle>教师</TD> <TD align=middle>课程简介</TD> <TD align=middle>开设地点</TD> <TD align=middle>课程学分</TD> <TD align=middle>人数限额<BR> (最多/最少)</TD> <TD align=middle>已选<BR> 人数</TD> </TR> <% set RS_KCLB=Server.CreateObject("ADODB.Recordset") RS_KCLB_SQL="select * from kcfl ORDER BY KCLBID ASC" RS_KCLB.open RS_KCLB_SQL,conn,1,1 if RS_KCLB.Recordcount<>0 then do while not RS_KCLB.eof set RS=Server.CreateObject("ADODB.Recordset") SQL="select * from 教师表_teacher where kcfl='"&RS_KCLB("KCLBID")&"' and sfks='1' ORDER BY ID ASC" RS.open SQL,conn,1,1 if RS.Recordcount<>0 then i=1 do while not RS.eof %> <% if i=1 then %> <TR bgColor=#ffffff height=25> <TD align=middle rowSpan=<%=RS.Recordcount%> ><a href="test.asp?kclb=<%=RS_KCLB("KCLB")%>"><%=RS_KCLB("KCLB")%></a></TD> <TD align=middle><%=rs("kcbh")%></TD> <TD align=left> <A title=点击这里查看简介 href="kc_show.asp?id=<%=rs("id")%>" target=_blank><%=rs("kcmc")%> </A></TD> <TD align=middle><%=rs("zsxm")%></TD> <TD align=middle><A href="kc_show.asp?id=<%=rs("id")%>" target=_blank>查看</A></TD> <TD align=middle><%=rs("skdd")%></TD> <TD align=middle><%=rs("kcxf")%></TD> <TD align=middle><%=rs("xzrs")%></TD> <TD align=middle><%=rs("yxrs")%></TD> </TR> <% i=i+1 else %> <TR bgColor=#ffffff height=25> <TD align=middle><%=rs("kcbh")%></TD> <TD align=left> <A title=点击这里查看简介 href="kc_show.asp?id=<%=rs("id")%>" target=_blank><%=rs("kcmc")%> </A></TD> <TD align=middle><%=rs("zsxm")%></TD> <TD align=middle><A href="kc_show.asp?id=<%=rs("id")%>" target=_blank>查看</A></TD> <TD align=middle><%=rs("skdd")%></TD> <TD align=middle><%=rs("kcxf")%></TD> <TD align=middle><%=rs("xzrs")%></TD> <TD align=middle><%=rs("yxrs")%></TD> </TR> <% end if i=i+1 rs.movenext loop end if rs.close set rs=nothing RS_KCLB.movenext loop RS_KCLB.close set RS_KCLB=nothing end if call CloseDatabase() %> <TR bgColor=#ffffff height=25> <TD align=middle colSpan=9><A href="xuanke.asp">我要开始选课 >></A></TD> </TR> </TBODY> </TABLE> <p align="center"> </p> <p align="center"> </p> <p align="center"><a href="">首页</a> <a href="fyfy.asp?page=<%=epage-1%>">前一页</a> <a href="fyfy.asp?page=<%=epage+1%>">后一页</a> <a href="fyfy.asp?page=<%=rs.pagecount%>">末页</a></p> <p align="center">现在是第<%=epage%>页一共有<%=rs.pagecount%>页</p> <% conn.close() %>