读书人

循环多出一列,该怎么处理

发布时间: 2012-02-08 19:52:21 作者: rapoo

循环多出一列
共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
%>


[解决办法]
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
%>

读书人网 >ASP

热点推荐