我这里是个分页的代码,主要实现的功能是每页显示2行2列(4个产品),但是这个代码有写问题,结果每一页显示的是一样的内容.请高手帮我斧正一下! <!-- #include file="inc/conn.asp" --> <!-- #include file="top.asp" -->
<% Set rsArticle= Server.CreateObject("ADODB.Recordset") rs.Open "Select * From product Order By UpdateTime DESC",conn,3 '首页公告调用数目 elite=rs("elite") passed=rs("passed") rsArticle.Open "Select * From product where elite=1 and passed=1 Order By UpdateTime DESC",conn,3
MaxPerPage=4 '取得页数,并判断留言输入的是否数字类型的数据,如不是将以第一页显示 dim text,checkpage text="0123456789" Rs.PageSize=MaxPerPage for i=1 to len(request("page")) checkpage=instr(1,text,mid(request("page"),i,1)) if checkpage=0 then exit for end if next
If checkpage<>0 then If NOT IsEmpty(request("page")) Then CurrentPage=Cint(request("page")) If CurrentPage < 1 Then CurrentPage = 1 If CurrentPage > Rs.PageCount Then CurrentPage = Rs.PageCount Else CurrentPage= 1 End If If not Rs.eof Then Rs.AbsolutePage = CurrentPage end if Else CurrentPage=1 End if
call showpages call list
If Rs.recordcount > MaxPerPage then call showpages end if
'显示帖子的子程序 Sub list()%> <table width="458" height="19" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="377" bgcolor="#E5EACE"> <% Response.write "<strong>-> 全部-</font>" Response.write "共" & Cstr(Rs.RecordCount) & "条FAQ公告</strong>" Response.write "<strong>第</font>" & "<font color=#FF0000>" & Cstr(CurrentPage) & "</font>" & "/" & Cstr(rs.pagecount) & "</strong>" If currentpage > 1 Then response.write "<strong><a href='index01.asp?&page="+cstr(1)+"'>首页</font></a><font color='#ffffff'> </font></strong>" Response.write "<strong><a href='index01.asp?page="+Cstr(currentpage-1)+"'>上一页</font></a></strong>" Else Response.write "<strong>上一页 </font></strong>" End if If currentpage < Rs.PageCount Then Response.write "<strong><a href='index01.asp?page="+Cstr(currentPage+1)+"'>下一页</a>" Response.write "<a href='index01.asp?page="+Cstr(Rs.PageCount)+"'>尾页</a></strong>" Else Response.write "" Response.write "<strong>下一页</strong> " End if 'response.write "</td><td align='right'>" 'response.write "转到:<input type='text' name='page' size=4 maxlength=4 class=smallInput value="&Currentpage&">" 'response.write "<input class=buttonface type='submit' value='Go' name='cndok'>" %> </td> </tr> <tr> <td height="1" colspan="2" bgcolor="#999999" width="458"></td> </tr> </table>
<% If rs.eof and rs.bof then call showpages response.write "" response.end End if %> <% if not rs.eof then i=0 do while not rs.eof %>
<% if not rsArticle.eof then rsArticle.movefirst %> <table width="170" border="1" width="315" cellpadding="1" cellspacing="0" bordercolordark="#FFFFFF" bordercolorlight="#999999" align=center frame=void>
<% do while not rsArticle.eof %> <tr > <% for h=1 to 2 if not rsArticle.eof then %> <td> <table width="170" border="0" cellpadding="0" cellspacing="0" align=center> <tr > <td align="center" valign="middle" height=105 colspan=2><a href="<%=rsArticle("DefaultPicUrl")%>" target=_blank><img border=0 src="<%=rsArticle("DefaultPicUrl")%>" width=100 height=100></a></td> </tr> <tr> <td align="center" valign="middle" height=15>产品名称:</td> <td valign="middle" height=15><a href="ArticleShow.asp?ArticleID=<%=rsArticle("articleid")%>" target=_blank><%=rsArticle("Title")%></a></td> </tr> <tr > <td align="center" valign="middle" height=15>产品类别:</td> <td valign="middle"><a href="Product.asp?BigClassName=<%=rsArticle("BigClassName")%>" target=_blank><%=rsArticle("BigClassName")%></a></td> </tr> <tr > <td align="center" valign="middle" height=15>产品编号:</td> <td valign="middle"><%=rsArticle("Product_Id")%></td> </tr> <tr > <td align="center" valign="middle" height=15 colspan=2><a href="ArticleShow.asp?ArticleID=<%=rsArticle("articleid")%>" target="_blank"><img src="Img/arrow_7.gif" border=0></a> <a href="javascript:eshop(<%=rsArticle("Product_Id")%>)"><img src="img/arrow_8.gif" border=0></a></td> </tr> </table> </td>
<% else %> <td> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <TD align=center height=28 valign=middle><font color=red>无产品</font></td> </tr> </Table> </td> <% end if rsArticle.movenext next %> </tr> <% loop %> <tr> <td align=right colspan=3><a href="cpjjindex.asp" target="_blank"><font color=red>more...</font></a> </td> <tr> </table> <% else %> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr> <TD align=center height=28 valign=middle><font color=red>无产品</font></td> </tr> </Table> <% end if rsArticle.close rs.close %>
<% i=i+1 if i >= MaxPerpage then exit do rs.movenext loop end if %> <%end sub%> 蓝色代码是控制分页的! 黑色代码是控制每页显示2行2列的! 请各位帮忙看看!谢谢!