記錄的分批輸出表格

mzcih 2004-11-22 02:39:57
Select id From Test '表有10條記錄.

<table border="1">
<tr>
<%Do While Not rs.EOF%>
<td>rs("id")</td>
<%
rs.MoveNext
Loop
%>
</tr>
</table>
以上是將所有記錄輸出同一個表格.

想實現,每需出5 條記錄便換到第二個表格中繼續需出.10條記錄,變是輸出二個表格.如此類推,不知有什麼好方法!
預想結果如下:

<table border="1">
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
</tr>
</table>
<table border="1">
<tr>
<td>6</td>
<td>7</td>
<td>8</td>
<td>9</td>
<td>10</td>
</tr>
</table>
...全文
140 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
mzcih 2004-11-22
  • 打赏
  • 举报
回复
厲害,一回貼就發現二張新回貼.夠快!
mzcih 2004-11-22
  • 打赏
  • 举报
回复
TO:jiank(金蛇郎君来杀鸡), wggipkhgef(不想说乔丹)


jiank(金蛇郎君来杀鸡)的加多句If Rs.Eof Then Exit For就更好,防止不夠5條記錄就出錯.

最后:謝謝大家的幫忙. ^_^
yjbnew 2004-11-22
  • 打赏
  • 举报
回复
dim i
i=0
Do While Not rs.EOF%>
if (i mod 5)=0 then %>
<table border="1">
%>
<tr>
<td>rs("id")</td>
</tr>
<%if (i mod 5)=0 then %>
</table>
<% rs.movenext
i=i+1
loop%>
yjbnew 2004-11-22
  • 打赏
  • 举报
回复
<%

dim i
i=0
Do While Not rs.EOF%>
i=i+1
if (i mod 5)=0 then %>
<table border="1">
%>
<tr>
<td>rs("id")</td>
</tr>
<%if (i mod 5)=0 then %>
</table>
<% rs.movenext
loop%>
butcher2002 2004-11-22
  • 打赏
  • 举报
回复
<%
if not rs.eof and rs.bof then
n=cint((rs.recordcount-1)/5)
for m=0 to n
dim i
Reponse.Write("<table border=1><tr>")&vbcrlf
for i=m*5+1 to m*5+5
if not rs.eof then
Reponse.Wrtie("<td>"&rs("id")&"</td>")&vbcrlf
end if
rs.movenext
next
Reponse.Write("</tr></table>")&vbcrlf
next
end if
%>
如果是1条记录 只显示1页
5条记录1页
6条记录 (6-1)/5 =1 0,1是2页
10条记录 (10-1)/5=1 2页
11条记录 (11-1)/5=2 3页
wggipkhgef 2004-11-22
  • 打赏
  • 举报
回复
for i=1 to rs.recordcount
if i mod 5=0 then
response.write"<table border='1'><tr>"
if not rs.eof then
Reponse.Wrtie"<td>"&rs("id")&"</td>"
end if
response.write"</tr></table>"
end if
next
mzcih 2004-11-22
  • 打赏
  • 举报
回复
汗!我不是臺灣人,只是以前這間是港資公司而已.:(
dorryyang 2004-11-22
  • 打赏
  • 举报
回复
呵呵,太敏感了吧,除了大陆,其他很多地方用繁体啊
香港之类都是
dorryyang 2004-11-22
  • 打赏
  • 举报
回复
和分页的实现方法差不多
gu1dai 2004-11-22
  • 打赏
  • 举报
回复
台湾同胞阿?高手来教教阿
jiank 2004-11-22
  • 打赏
  • 举报
回复
<%While Not rs.EOF
dim i
Reponse.Write("<table border=1><tr>")&vbcrlf
for i=1 to 5
if not rs.eof then
Reponse.Wrtie("<td>"&rs("id")&"</td>")&vbcrlf
end if
rs.movenext
next
Reponse.Write("</tr></table>")&vbcrlf
wend
%>
手机APP开发 2004-11-22
  • 打赏
  • 举报
回复
怎么全是繁体?你是不是台湾人啊,蓝的还是绿的?

28,391

社区成员

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

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