又是循环搞不懂了郁闷

hailun 2007-01-03 04:15:11
下面的实现应该是

图片1 图片1 图片1
说明1 说明1 说明1

图片1 图片1 图片1
说明1 说明1 说明1

图片1 图片1 图片1
说明1 说明1 说明1
分页
有错误,我点上一页或下一页,首页,尾页的时候始终是在本页,而不是下一条记录







<tr>
<td height="600" align="center" valign="top" style="word-break:break-all" >
<%
const MaxPerPage=5 '分页显示的纪录个数
dim sql
dim rs
dim totalPut
dim CurrentPage
dim TotalPages
dim i,j


if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
set rs=server.createobject("adodb.recordset")
sql="select * from honor order by id desc"
rs.open sql,conn,1,1

if rs.eof and rs.bof then
response.write "<p align='center'>还没有任何留言!</p>"
else
totalPut=rs.recordcount
if currentpage<1 then
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
if currentPage=1 then
showContent
showpages
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpages
else
currentPage=1
showContent
end if
end if
rs.close
end if
set rs=nothing
conn.close
set conn=nothing
sub showContent
dim i
i=0
do while not (rs.eof or err) %>
<table width="100%" align="center" valign="middle">

<tr>
<%
set rs1=server.createobject("adodb.recordset")
sql1="select * from honor order by id desc"
rs1.open sql1,conn,1,1
i=1
j=0
do while not rs.eof
if j/9<>1 then
if i mod 3=0 then
%>

<td align="center" valign="middle"><table id="__01" width="172" height="133" border="0" cellpadding="0" cellspacing="0"><tr><td colspan=4> </td></tr>
<tr>
<td colspan="3"><img src="images/index_03_02_03_05_02_03_01.jpg" width="172" height="7" alt=""></td>
</tr>
<tr>
<td rowspan="2"><img src="images/index_03_02_03_05_02_03_02.jpg" width="6" height="126" alt=""></td>
<td width="160" height="119" align="center"><a href=hjshow.asp?id=<%=rs1("id")%>><img src=<%=rs1("img")%> width="159" height="118"></a></td>
<td rowspan="2"><img src="images/index_03_02_03_05_02_03_04.jpg" width="6" height="126" alt=""></td>
</tr>
<tr>
<td><img src="images/index_03_02_03_05_02_03_05.jpg" width="160" height="7" alt=""></td>
</tr>
<tr>
<td align="center" colspan="3"><table width="100%">
<tr>
<td><img src=img/new_title.jpg></td>
<td><strong><font color="red">
<%if len(rs1("title"))>12 then%>
<%=left(rs1("title"),12)%>...
<%else%>
<%=rs1("title")%>
<%end if%>
</font></strong> </td>
</tr>
</table></td>
</tr>
</table></td></tr><tr>
<%
j=j+1
else
%>
<td align="center" valign="middle"><table id="__01" width="172" height="133" border="0" cellpadding="0" cellspacing="0"><tr><td colspan=4> </td></tr>
<tr>
<td colspan="3"><img src="images/index_03_02_03_05_02_03_01.jpg" width="172" height="7" alt=""></td>
</tr>
<tr>
<td rowspan="2"><img src="images/index_03_02_03_05_02_03_02.jpg" width="6" height="126" alt=""></td>
<td width="160" height="119" align="center"><a href=hjshow.asp?id=<%=rs1("id")%>><img src=<%=rs1("img")%> width="159" height="118"></a></td>
<td rowspan="2"><img src="images/index_03_02_03_05_02_03_04.jpg" width="6" height="126" alt=""></td>
</tr>
<tr>
<td><img src="images/index_03_02_03_05_02_03_05.jpg" width="160" height="7" alt=""></td>
</tr>
<tr>
<td align="center" colspan="3"><table width="100%">
<tr>
<td><img src=img/new_title.jpg></td>
<td><strong><font color="red">
<%if len(rs1("title"))>12 then%>
<%=left(rs1("title"),12)%>...
<%else%>
<%=rs1("title")%>
<%end if%>
</font></strong> </td>
</tr>
</table></td>
</tr>
</table></td>
<%
j=j+1
end if
rs1.movenext
i=i+1
else
exit do
end if
loop
%>
<tr><td> </td></tr>
<tr>
<td colspan="2" align="center">

<% i=i+1
if i>=MaxPerPage then exit do
rs.movenext
loop
end sub
sub showpages()
dim n
if (totalPut mod MaxPerPage)=0 then
n= totalPut \ MaxPerPage
else
n= totalPut \ MaxPerPage + 1
end if
dim k

if currentpage=1 then
%>
首页 上一页
<%
else
%>
<a href=hjzs.asp?page=1>首页</a>
<a href=hjzs.asp?page=<%=(CurrentPage-1)%>>上一页</a>
<%
end if
if n-currentpage<1 then
%>
下一页 尾页
<%else%>

<a href=hjzs.asp?page=<%=(CurrentPage+1)%>>下一页</a>
<a href=hjzs.asp?page=<%=n%>>尾页</a>
<%
end if

end sub
%>

</td>
</tr>
</table>
</td>
</tr>
...全文
164 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hailun 2007-01-03
  • 打赏
  • 举报
回复
就是一个图片循环和一个分页
hzl126 2007-01-03
  • 打赏
  • 举报
回复
把我给看晕了
tantaiyizu 2007-01-03
  • 打赏
  • 举报
回复
代码长 不知道你的问题所在!

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧