主题:[原创]我做了一个分页,问题就出现了!
zlina521
[专家分:0] 发布于 2007-11-15 16:44:00
我本来想做一个分页,每页输出6个数据,一行3个分2行输出!但是程序写出来,一行3条数据显示没有问题,就是记录多了在第一页把所有的记录都显示出来了!没有起到只有输出2行的效果!
我看了好久也没看出问题,可能是我水平有限,望各位高手能帮帮忙!
最后更新于:2007-11-15 16:56:00
回复列表 (共7个回复)
沙发
zlina521 [专家分:0] 发布于 2007-11-15 16:47:00
代码是这样的,因为不知道错在哪里,所以只有把代码都贴出来,有点长望高手能耐心看下!
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="18"></td>
</tr>
<tr>
<td align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="147%" colspan="3" align="center" valign="middle">
<%
set rs=server.CreateObject("adodb.recordset")
sql="select top 6 * from Product where BigClassName='产品配件' order by UpdateTime desc"
'response.write(sql)
rs.open sql,conn,1,1
if rs.eof then
response.write "<font color='red'>"
response.write "没有相应资料"
response.write "</font>"
response.end
else
rs.PageSize =6 '每页记录条数
iCount=rs.RecordCount '记录总数
iPageSize=rs.PageSize
maxpage=rs.PageCount
page=request("page")
if Not IsNumeric(page) or page="" then
page=1
else
page=cint(page)
end if
if page<1 then
page=1
elseif page>maxpage then
page=maxpage
end if
rs.AbsolutePage=Page
if page=maxpage then
x=iCount-(maxpage-1)*iPageSize
else
x=iPageSize
end if
i=0
end if
%>
<%do until rs.eof or rs.bof%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<%i=1%>
<%do until rs.eof or rs.bof or i>=4%>
<td width="33%" align="left" valign="top">
板凳
zlina521 [专家分:0] 发布于 2007-11-15 16:48:00
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="10" height="26" align="left" valign="middle" bgcolor="#800237"></td>
<td width="186" align="center" valign="middle" bgcolor="#800237"><%=rs("SmallClassName")%></td>
</tr>
<tr>
<td colspan="2" align="center" valign="top">
<%if date()-rs("UpdateTime")<6 then%>
<a href="showpro.asp?id=<%=rs("ArticleID")%>" target="_blank"><img src="
<%if trim(rs("picurl"))<>"" then%>
/manage<%=rs("picurl")%>
<%else%>
images/noimg.jpg
<%end if%>" width="207" height="120" border="0" /></a>
<%else%>
<%response.write "<font color='red'>"
response.write "没有相应资料"
response.write "</font>"
response.end%>
<%end if%>
</td>
</tr>
<tr>
<td height="24" colspan="2" align="center" valign="middle" bgcolor="#110009" class="f2">型号:<%=rs("Spec")%></td>
</tr>
</table></td>
<td width="33%" align="left" valign="top"> </td>
<td width="33%" align="left" valign="top"> </td>
<%
i=i+1
if i<4 then
rs.movenext
end if
loop
%>
</tr>
<tr>
<td height="15" colspan="3"></td>
</tr>
</table>
</td>
</tr>
</table>
<%
if not rs.eof or rs.bof then
rs.movenext
end if
loop
rs.close
set rs=nothing
%>
3 楼
zlina521 [专家分:0] 发布于 2007-11-15 16:48:00
<table width="92%" height="10" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center"> </td>
</tr>
<tr>
<td align="center"> </td>
</tr>
<tr>
<td align="center">共<font color=red><%=maxpage%></font>页 第<%=page%>页 <font color=666666>
<%if page-1>0 then%>
<a href="showzxc.asp?page=<%=page-1%>">上一页</a>
<%else%>
<font color=666666>上一页</font>
<%end if%>
<%if page+1<=maxpage then%>
<a href="showzxc.asp?page=<%=page+1%>">下一页</a>
<%else%>
<font color=666666>下一页</font>
<%end if%>
</font>共
<% =iCount %>
条记录 </td>
</tr>
</table>
</td>
</tr>
</table>
4 楼
wangsdong [专家分:21390] 发布于 2007-11-15 16:51:00
没有耐心,还不如你直接你想要做成什么效果说出来
5 楼
zlina521 [专家分:0] 发布于 2007-11-15 16:58:00
效果我也说了啊,就是在一个页面上输出6张图片,一行3张,然后记录多了就分页显示!
6 楼
wangsdong [专家分:21390] 发布于 2007-11-15 17:10:00
<table width="500" border="1">
<%
size=6
For i=1 To size
If i Mod 2=1 Then
response.write "<tr>"
End If
response.write "<td>"&i&"</td>"
If i Mod 2=0 Then
response.write "</tr>"
End If
next
%>
</table>
给你一个简单的例子,你试着改一下你的代码
7 楼
yaozheng [专家分:28410] 发布于 2007-11-15 17:11:00
在你的第一层循环的时候,要限制输出数量
<%do until rs.eof or rs.bof and i<=6%>
我来回复