asp读取access实现分行
请高手帮我写一段代码,循环读取数据库某一字段时,当读取到第5的倍数条记录时输出</tr><tr>,否则继续循环读取。只需要实现这一功能,其他的<table><tr><td...
请高手帮我写一段代码,循环读取数据库某一字段时,当读取到第5的倍数条记录时输出</tr><tr>,否则继续循环读取。
只需要实现这一功能,其他的<table><tr><td>我机动输入。
<tr>
<%do while not rs.eof%>
<td>
<%读取代码%>
<%i=0%>
<%while not rs.eof%>
<%i=i+1%>
<%if i%5==0 then%>
<%="</tr><tr>"%>
<%end if%>
<%="</td><td>"%>
<%wend%>
</td>
<%rs.movenext loop%></tr>
到底错在哪里??? 展开
只需要实现这一功能,其他的<table><tr><td>我机动输入。
<tr>
<%do while not rs.eof%>
<td>
<%读取代码%>
<%i=0%>
<%while not rs.eof%>
<%i=i+1%>
<%if i%5==0 then%>
<%="</tr><tr>"%>
<%end if%>
<%="</td><td>"%>
<%wend%>
</td>
<%rs.movenext loop%></tr>
到底错在哪里??? 展开
2个回答
展开全部
给你一段参考代码
<%
Dim ipagecount
Dim ipagecurrent
Dim strorderBy
Dim irecordsshown
if request.querystring("page")="" then
ipagecurrent=1
else
ipagecurrent=cint(request.querystring("page"))
end if
sql="查询数据库语句"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.pagesize ='每页显示个数 列的倍数
rs.OPEN sql,Conn,1,1
ipagecount = rs.pagecount
recordcount_a=rs.recordcount
Response.Write"<table width='95%' border='0' cellspacing='0' cellpadding='5'>"
top=1
if rs.bof and rs.eof then
response.write "<tr><td align='center'>Sorry!未找到相关系列产品信息!</tr></td>"
else
rs.absolutepage = ipagecurrent
irecordsshown = 0
do while not rs.eof and irecordsshown<rs.pagesize
Response.Write"<tr align='center'>"
for i=1 to 3 '列数
Response.Write"<td width='25%'>"
if not rs.eof then
%>
<table width="27%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#EBEBEB">
<tr>
<td><div align="center"><a href="product_show.asp?pic_id=<%=rs("yhr_product_id")%>" target="_blank" class=img>
<img src="../<%=rs("图片地址字段")%>" alt="<%=rs("图片名称字段")%>" width="186" height="186" border="1" class="img">
</a></div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td><div align="center"><a href="显示网页图片的页.asp?pic_id=<%=rs("图片ID")%>" target="_blank" class=img><%=rs("图片名称")%></a></div></td>
</tr>
</table>
<%
top=top+1
irecordsshown=irecordsshown+1
rs.movenext
end if
next
Response.Write"</tr>"
if top> 图片显示个数,列的倍数 then exit do
loop
end if
rs.Close
set rs=nothing
Response.Write"</table>"
Response.Write"<table align='center'><tr><td height='20'>共有<font color=red> "&recordcount_a&" </font>个 每页显示<font color=red> "&yhr_site_pro_num&" </font>个 共<font color=red> "&ipagecount&" </font>页 当前为第 "&ipagecurrent&" 页 "
if ipagecurrent=1 then
Response.Write"首页 | "
else
Response.Write"<a href='?page=1&classid="&request.querystring("classid")&"' class=img>首页</a> | "
end if
if ipagecurrent=1 then
Response.Write"上一页 | "
else
Response.Write"<a href='?page="&ipagecurrent-1&"&classid="&request.querystring("classid")&"'>上一页</a> | "
end if
if ipagecount>ipagecurrent then
Response.Write"<a href='?page="&ipagecurrent+1&"&classid="&request.querystring("classid")&"'>下一页</a> "
else
Response.Write"下一页"
end if
if ipagecount>ipagecurrent then
Response.Write"| <a href='?page="&ipagecount&"&classid="&request.querystring("classid")&"'>末页</a> "
else
Response.Write"| 末页 "
end if
Response.Write"</td></tr></table>"
%>
<%
Dim ipagecount
Dim ipagecurrent
Dim strorderBy
Dim irecordsshown
if request.querystring("page")="" then
ipagecurrent=1
else
ipagecurrent=cint(request.querystring("page"))
end if
sql="查询数据库语句"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.pagesize ='每页显示个数 列的倍数
rs.OPEN sql,Conn,1,1
ipagecount = rs.pagecount
recordcount_a=rs.recordcount
Response.Write"<table width='95%' border='0' cellspacing='0' cellpadding='5'>"
top=1
if rs.bof and rs.eof then
response.write "<tr><td align='center'>Sorry!未找到相关系列产品信息!</tr></td>"
else
rs.absolutepage = ipagecurrent
irecordsshown = 0
do while not rs.eof and irecordsshown<rs.pagesize
Response.Write"<tr align='center'>"
for i=1 to 3 '列数
Response.Write"<td width='25%'>"
if not rs.eof then
%>
<table width="27%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bordercolor="#EBEBEB">
<tr>
<td><div align="center"><a href="product_show.asp?pic_id=<%=rs("yhr_product_id")%>" target="_blank" class=img>
<img src="../<%=rs("图片地址字段")%>" alt="<%=rs("图片名称字段")%>" width="186" height="186" border="1" class="img">
</a></div></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td><div align="center"><a href="显示网页图片的页.asp?pic_id=<%=rs("图片ID")%>" target="_blank" class=img><%=rs("图片名称")%></a></div></td>
</tr>
</table>
<%
top=top+1
irecordsshown=irecordsshown+1
rs.movenext
end if
next
Response.Write"</tr>"
if top> 图片显示个数,列的倍数 then exit do
loop
end if
rs.Close
set rs=nothing
Response.Write"</table>"
Response.Write"<table align='center'><tr><td height='20'>共有<font color=red> "&recordcount_a&" </font>个 每页显示<font color=red> "&yhr_site_pro_num&" </font>个 共<font color=red> "&ipagecount&" </font>页 当前为第 "&ipagecurrent&" 页 "
if ipagecurrent=1 then
Response.Write"首页 | "
else
Response.Write"<a href='?page=1&classid="&request.querystring("classid")&"' class=img>首页</a> | "
end if
if ipagecurrent=1 then
Response.Write"上一页 | "
else
Response.Write"<a href='?page="&ipagecurrent-1&"&classid="&request.querystring("classid")&"'>上一页</a> | "
end if
if ipagecount>ipagecurrent then
Response.Write"<a href='?page="&ipagecurrent+1&"&classid="&request.querystring("classid")&"'>下一页</a> "
else
Response.Write"下一页"
end if
if ipagecount>ipagecurrent then
Response.Write"| <a href='?page="&ipagecount&"&classid="&request.querystring("classid")&"'>末页</a> "
else
Response.Write"| 末页 "
end if
Response.Write"</td></tr></table>"
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询