循环多出一列

hailun 2007-01-13 10:22:23
共8条记录
8 7 6
5 4 3
2 1

但我下面这个是
8 7 6
5 4 3
3 2 1 //此处多个3不知道哪里错了


<!--#include file="inc/conn.asp"-->
<%
set rs1=server.createobject("adodb.recordset")
sql1="select * from honor order by id desc"
rs1.open sql1,conn,1,1
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
totalPut=rs1.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 totalput,MaxPerPage
else
if (currentPage-1)*MaxPerPage<totalPut then
rs1.move (currentPage-1)*MaxPerPage
showContent
showpages totalput,MaxPerPage
else
currentPage=1
showContent
showpages totalput,MaxPerPage
end if
end if
sub showContent
%>
<table width="100%" align="center" valign="middle" height="100%">

<tr>
<%
i=0
do while not rs1.eof
%>

<td align="center" width="33%"><Table><tr><td>
<a href="连接地址" target="_blank"><img src="记录的图片路径如:><%=rs1("img")%>" alt="图片说明,可不填,如:<%=rs1("title")%>" width="110" height="143" border="0"></a>
</td>
</tr>
<tr><td align="center"><%=rs1("title")%>-->图片标题
</td></tr></Table></td>
<%
rs1.movenext
i=i+1
if i mod 3=0 then
%>
</tr><tr>
<%
end if
if i>MaxPerPage then exit do
loop
%></tr>
<tr><td> </td></tr> </table>
<%
rs1.close '释放资源
set rs1=nothing
end sub
Function showpages(totalPut,MaxPerPage)
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=About1.asp?page=1>首页</a>
<a href=About1.asp?page=<%=(CurrentPage-1)%>>上一页</a>
<%
end if
if n-currentpage<1 then
%>
下一页 尾页
<%else%>

<a href=About1.asp?page=<%=(CurrentPage+1)%>>下一页</a>
<a href=About1.asp?page=<%=n%>>尾页</a>
<%
end if
%>
<%
end Function
%>
...全文
218 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
hailun 2007-01-16
  • 打赏
  • 举报
回复
<!--#include file="inc/conn.asp"-->
<%
set rs1=server.createobject("adodb.recordset")
sql1="select * from honor order by id desc"
rs1.open sql1,conn,1,1
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
totalPut=rs1.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 totalput,MaxPerPage
else
if (currentPage-1)*MaxPerPage<totalPut then
rs1.move (currentPage-1)*MaxPerPage
showContent
showpages totalput,MaxPerPage
else
currentPage=1
showContent
showpages totalput,MaxPerPage
end if
end if
sub showContent
%>
<table width="100%" align="center" valign="middle" height="100%">

<tr>
<%
i=0
do while not rs1.eof
%>

<td align="center" width="33%"><Table><tr><td>
<a href="连接地址" target="_blank"><img src="记录的图片路径如:><%=rs1("img")%>" alt="图片说明,可不填,如:<%=rs1("title")%>" width="110" height="143" border="0"></a>
</td>
</tr>
<tr><td align="center"><%=rs1("title")%>-->图片标题
</td></tr></Table></td>
<%
rs1.movenext
i=i+1
if i mod 3=0 then
%>
</tr><tr>
<%
end if
if i>MaxPerPage-1 then exit do
loop
%></tr>
<tr><td> </td></tr> </table>
<%
rs1.close '释放资源
set rs1=nothing
end sub
Function showpages(totalPut,MaxPerPage)
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=About1.asp?page=1>首页</a>
<a href=About1.asp?page=<%=(CurrentPage-1)%>>上一页</a>
<%
end if
if n-currentpage<1 then
%>
下一页 尾页
<%else%>

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


自己搞定了,也可以这样
tangqiaojie 2007-01-16
  • 打赏
  • 举报
回复
const MaxPerPage=6 '分页显示的纪录个数

...
i=1
do while not rs1.eof%>
<td align="center" width="33%"><Table><tr><td>
<a href="" target="_blank"><img src="记录的图片路径如:><%=rs1("pic")%>" alt="图片说明,可不填,如:<%=rs1("name")%>" width="110" height="143" border="0"></a>
</td>
</tr>
<tr><td align="center"><%=rs1("id")%>-->图片标题
</td></tr></Table></td>
<%
if i mod 3=0 then response.Write "</tr><tr>"
i=i+1
rs1.movenext
if i>MaxPerPage then exit do
loop
%>
hailun 2007-01-13
  • 打赏
  • 举报
回复
我还是没有找到哪里不对呀
hailun 2007-01-13
  • 打赏
  • 举报
回复
不是那里吧,
是的话要怎么改
liu_87663663 2007-01-13
  • 打赏
  • 举报
回复
if i mod 3=0 then n 错误出现在这里

28,391

社区成员

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

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