标题:[原创]我这里是个分页的代码,主要实现的功能是每页显示2行2列(4个产品),但是 ...
只看楼主
skag
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2005-5-30
 问题点数:0 回复次数:3 
[原创]我这里是个分页的代码,主要实现的功能是每页显示2行2列(4个产品),但是这个代

我这里是个分页的代码,主要实现的功能是每页显示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>&nbsp;&nbsp;" 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>&nbsp;<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>&nbsp;&nbsp;</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列的! 请各位帮忙看看!谢谢!

搜索更多相关主题的帖子: elite 代码 passed 
2005-07-07 09:41
skag
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2005-5-30
得分:0 
有没有高手在?
帮我看看呀!
2005-07-07 18:40
zhsm_0011
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2005-5-19
得分:0 
看不懂,你写的东西,太多了,也懒得看了,我这里有作过每页显示,8个记录,分二行显示的,可以成功运行的。显示的是,8个不同的数据库中的图片,自己模仿吧!

&lt;!--#include file="sub/listpages.asp"--&gt;
&lt;title&gt;产品展示&lt;/title&gt;
&lt;/head&gt;
&lt;!--#include file="conn.asp"--&gt;
&lt;!--#include file="bgsub.asp"--&gt;
  &lt;table width="778" height="700" border="0" align="center" cellpadding="0" cellspacing="0"&gt;
    &lt;tr&gt;
      &lt;td width="186"&gt;&lt;table width="186" border="0" align="center" cellpadding="0" cellspacing="0"&gt;
          &lt;tr&gt;
            &lt;td height="26" valign="bottom"&gt;&lt;img src="images/index_09.gif" width="186" height="26"&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td width="186" height="674" background="images/index_11.gif"&gt;&amp;nbsp;&lt;/td&gt;
          &lt;/tr&gt;
        &lt;/table&gt;&lt;/td&gt;
      &lt;td align="center" bgcolor="#FFFFFF"&gt;
        &lt;%dim rs
 dim sql
 pmcount=8                 //每页记录
 set rs=server.CreateObject("adodb.recordset")
 sql = "select id,filename,pic from design order by id desc"
 rs.pagesize = pmcount                    '
 rs.open sql,conn,1,1
if rs.eof and rs.bof then
  response.Write("&lt;p&gt;&lt;P&gt;&lt;p align=center&gt;&lt;font color=red&gt;对不起,没有相关纪录!&lt;/font&gt;")
end if
if not (rs.eof and rs.bof) then          '
totalrec = RS.RecordCount                'totalrec:总记录条数
mpage=rs.pagecount                       'mpage:总记录页数
currentpage = request("page")            'currentpage:从提交的page中得到当前页
If currentpage &lt;&gt; "" then
  currentpage = cint(currentpage)        '将currentpage转换为数值型的
  if currentpage &lt; 1 then
     currentpage = 1
  end if
else
currentpage = 1
end if
if currentpage*pmcount &gt; totalrec and not((currentpage-1)*pmcount &lt; totalrec)then
currentPage=1
end if
rs.absolutepage = currentpage                 
rowcount = rs.pagesize
m=rowcount/2                      //分两行,一行8/2个记录
 %&gt;
        &lt;table border="0" cellpadding="0" cellspacing="0"&gt;
          &lt;%do while not rs.eof and rowcount&gt;0
    %&gt;
          &lt;tr&gt;
            &lt;%for i=1 to m
    if not rs.eof  then
    %&gt;
            &lt;td width="140" height="100" align="center" valign="top"&gt;&lt;a onClick="Javascript:OpenSmallWindows('zhanshi.asp?id=&lt;%= rs("id") %&gt;')"  target="_blank"&gt;&lt;img  src=&lt;%= rs("pic") %&gt; width="120" height="80" border="0"&gt;&lt;/a&gt;&lt;br&gt;
              &lt;%= rs("filename") %&gt;
              &lt;%
   rowcount=rowcount-1
   rs.movenext
   end if
   %&gt;
              &lt;%next%&gt;
            &lt;/td&gt;
          &lt;/tr&gt;
          &lt;%loop%&gt;
          &lt;%end if
   rs.close
   conn.close
   set rs=nothing
   set conn=nothing
   %&gt;
        &lt;/table&gt;
        &lt;br&gt;
        &lt;%call listPages()%&gt;
      &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
  &lt;script language="javascript"&gt;
function OpenSmallWindows(strURL)
{
window.open (strURL,"_blank",
"status=no,resizable=1,toolbar=no,menubar=no,scrollbars=yes,width=450,height=400,left=150,top=50");
}
&lt;/script&gt;
 &lt;!--#include file="button.asp"--&gt;
2005-07-07 20:43
skag
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2005-5-30
得分:0 
分页显示问题.谁帮帮我!
分页显示问题.谁帮帮我!
2005-07-15 16:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-22338-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.054631 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved