totalPut=rs.recordcount'记录总的文章数 if currentpage<1 then'判断当前页是否小于1 currentpage=1 end if if (currentpage-1)*MaxPerPage>totalput then'判断是否已到尾页 if (totalPut mod MaxPerPage)=0 then currentpage= totalPut \ MaxPerPage else currentpage= totalPut \ MaxPerPage + 1 end if
end if '下面是将查询结果分页显示 '函数showpage显示页数的基本信息,包括首页,上一页,下一页,尾页,跳转到某页,下面有 '函数showContent显示文章的基本信息,下面有 if currentPage=1 then showpage totalput,MaxPerPage,"mymanage.asp" showContent showpage totalput,MaxPerPage,"mymanage.asp" else if (currentPage-1)*MaxPerPage<totalPut then rs.move (currentPage-1)*MaxPerPage dim bookmark bookmark=rs.bookmark showpage totalput,MaxPerPage,"mymanage.asp" showContent showpage totalput,MaxPerPage,"mymanage.asp" else currentPage=1 showpage totalput,MaxPerPage,"mymanage.asp" showContent showpage totalput,MaxPerPage,"mymanage.asp" end if end if rs.close end if set rs=nothing conn.close set conn=nothing '函数showContent显示文章的基本信息 sub showContent dim i i=0
%> <div align="center"> <center> <table border="0" cellspacing="1" width="100%" bordercolorlight="#000000" bordercolordark="#FFFFFF" cellpadding="0" bgcolor="#000000"> <tr bgcolor="#304D7C"> <td width="50" align="center" height="20"><strong><font color="#FFFFFF">ID号</font></strong></td> <td width="389" align="center"><strong><font color="#FFFFFF">文章标题</font></strong></td> <td width="148" align="center"><strong><font color="#FFFFFF">日期</font></strong></td> </tr> <%do while not rs.eof%> <tr bgcolor="#FFFFFF"> <td height="23" width="50"> <p align="center"><%=rs("newsid")%> </td> <td width="389"> <p align="center"><a href="<%=rs("path")%>/<%=rs("N_Fname")%>"><%=rs("title")%></a> </td> <td width="148" bgcolor="#FFFFFF"> <p align="center"><%=rs("dateandtime")%> </td> </tr> <% i=i+1 if i>=MaxPerPage then exit do rs.movenext loop %> </table> </center> </div> <% end sub '函数showpage显示页数的基本信息,包括首页,上一页,下一页,尾页,跳转到某页 function showpage(totalnumber,maxperpage,filename) dim n if totalnumber mod maxperpage=0 then n= totalnumber \ maxperpage else n= totalnumber \ maxperpage+1 end if response.write "<form method=Post action="&filename&"?typeid="&typeid&">" response.write "<p align='center'> " if CurrentPage<2 then response.write "<font color='#000080'>首页 上一页</font> " else response.write "<a href="&filename&"?page=1&typeid="&typeid&">首页</a> " response.write "<a href="&filename&"?page="&CurrentPage-1&"&typeid="&typeid&">上一页</a> " end if if n-currentpage<1 then response.write "<font color='#000080'>下一页 尾页</font>" else response.write "<a href="&filename&"?page="&(CurrentPage+1)&"&typeid="&typeid&">" response.write "下一页</a> <a href="&filename&"?page="&n&"&typeid="&typeid&">尾页</a>" end if response.write "<font color='#000080'> 页次:</font><strong><font color=red>"&CurrentPage&"</font><font color='#000080'>/"&n&"</strong>页</font> " response.write "<font color='#000080'> 共<b>"&totalnumber&"</b>篇文章 <b>"&maxperpage&"</b>篇文章/页</font> " response.write " <font color='#000080'>转到:</font><input type='text' name='page' size=4 maxlength=10 class=smallInput value="¤tpage&">" response.write "<input class=buttonface type='submit' value='Goto' name='cndok'></span></p></form>" end function %> 只是觉得太复杂了.
[此贴子已经被作者于2005-5-27 21:01:37编辑过]