求助,读取数据的时候出现重复啦

dalongleng 2009-09-02 09:46:19
页面显示的地方是这样的。

<%Call NewsJCWListBGXZ("表 格 下 载",10)%>


然后调用的这个函数是这样的

'''''''''''''''''''''''''''''''''''''''''''''
'显示表格下载
'''''''''''''''''''''''''''''''''''''''''''''
Function NewsJCWListBGXZ(str,n)
if str="推荐内容" then
sql="select top "&n&" NewsID,Content,Title,D_SaveFileName,PostTime,MenuID,SubMenuID from News where ProFlag=1 order by PostTime desc"
else
sql="select top "&n&" news.newsid,news.Content,news.title,news.D_SaveFileName,news.posttime,news.menuid,news.submenuid from news,submenu where submenu.submenuid=news.submenuid and submenuitems='"&str&"' order by posttime desc"
end if
rs.open sql,cn,1,3
if rs.bof and rs.eof then
response.write "此栏目没有文章"
else
Response.Write "<table width='100%'>"
'Response.Write "<tr><td width='100%' colspan='2' height='20' style='background-image: url(images/tableline1.gif); background-repeat: no-repeat; background-position: left bottom' valign='bottom'>     <b>"&str&"</b></td><td></td></tr>"
do while not rs.eof
dim datlast,cid,shortdate,title,js
datlast=rs("PostTime")
shortdate=mid(datlast,1,instr(datlast," "))
cid=rs("menuid")
title=rs("title")
if len(title)>20 then title=mid(title,1,17)&"..."
for js = 1 to rs.recordcount
if rs("Content")<>"" then
If js Mod 2 = 0 Then Response.Write "</tr><tr>"
if cint(now() - datlast)<NewDate then
Response.Write "<td class='tdbgline' height='23'> <FONT class='d'>●</FONT> <a href='?cid="&rs("menuid")&"&sid="&rs("submenuid")&"&id="&rs("newsid")&"' title='"&rs("title")&"'>"&title&"</a> <img src='images/new.gif'></td>"
else
Response.Write "<td class='tdbgline' height='23'> <FONT class='d'>●</FONT> <a href='?cid="&rs("menuid")&"&sid="&rs("submenuid")&"&id="&rs("newsid")&"' title='"&rs("title")&"'>"&title&"</a></td>"
end if
If js Mod 2 = 1 Then Response.Write "</tr>"
If js = rs.RecordCount-1 And js Mod 2 = 0 Then
Response.Write "<td> </td></tr>"
End If
else
If js Mod 2 = 0 Then Response.Write "<tr>"

if cint(now() - datlast)<NewDate then
Response.Write "<td class='tdbgline' height='23'> <FONT class='d'>●</FONT> <a href='UploadFile/"&rs("D_SaveFileName")&"' Target='_blank' title='"&rs("title")&"'>"&title&"</a> <img src='images/new.gif'></td>"
else
Response.Write "<td class='tdbgline' height='23'> <FONT class='d'>●</FONT> <a href='UploadFile/"&rs("D_SaveFileName")&"' Target='_blank' title='"&rs("title")&"'>"&title&"</a></td>"
end if
If js Mod 2 = 1 Then Response.Write "</tr>"
If js = rs.RecordCount-1 And js Mod 2 = 0 Then
Response.Write "<td> </td></tr>"
End If
end if
next
sid=rs("submenuid")
js = js + 1
js = rs.recordCount
rs.movenext
loop
if str<>"推荐内容" then
Response.Write "<tr><td colspan='2' align='right'><br><a href='?cid="&cid&"&sid="&sid&"&style=all'><span id='ctlButtons'><img alt='更多' border='0' src='images/more.gif' hoverSrc='images/more1.gif'></span></a> </td></tr>"
end if
Response.Write "</table>"
end if
rs.close
End Function


请问我是把FOR循环的位置放错了么?
我 现在 里面是6条数据,
每个数据都同时显示了6次。
我要实现,每行显示2条数据,
也就是每显示两条数据,
就自动换到下一行显示。

当前截图。
...全文
95 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
dalongleng 2009-09-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 number123456 的回复:]
VBScript codefor js=1to rs.Recordcountdim datlast,cid,shortdate,title,js
datlast=rs("PostTime")
shortdate=mid(datlast,1,instr(datlast,""))
cid=rs("menuid") ¡­
[/Quote]

非常非常非常的感谢,调好了,

dalongleng 2009-09-02
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 number123456 的回复:]
VBScript codefor js=1to rs.Recordcountdim datlast,cid,shortdate,title,js
datlast=rs("PostTime")
shortdate=mid(datlast,1,instr(datlast,""))
cid=rs("menuid") ¡­
[/Quote]
还是不行,改完了一行就显示一条新闻
number123456 2009-09-02
  • 打赏
  • 举报
回复
    for js = 1 to rs.Recordcount
dim datlast,cid,shortdate,title,js
datlast=rs("PostTime")
shortdate=mid(datlast,1,instr(datlast," "))
cid=rs("menuid")
title=rs("title")
if len(title)>20 then title=mid(title,1,17)&"..."
if rs("Content")<>"" then
If js Mod 2 = 0 Then Response.Write "</tr><tr>"
if cint(now() - datlast)<NewDate then
Response.Write "<td class='tdbgline' height='23'> <FONT class='d'>●</FONT> <a href='?cid="&rs("menuid")&"&sid="&rs("submenuid")&"&id="&rs("newsid")&"' title='"&rs("title")&"'>"&title&"</a> <img src='images/new.gif'></td>"
else
Response.Write "<td class='tdbgline' height='23'> <FONT class='d'>●</FONT> <a href='?cid="&rs("menuid")&"&sid="&rs("submenuid")&"&id="&rs("newsid")&"' title='"&rs("title")&"'>"&title&"</a></td>"
end if
If js Mod 2 = 1 Then Response.Write "</tr>"
If js = rs.RecordCount-1 And js Mod 2 = 0 Then
Response.Write "<td> </td></tr>"
End If
else
If js Mod 2 = 0 Then Response.Write "<tr>"

if cint(now() - datlast)<NewDate then
Response.Write "<td class='tdbgline' height='23'> <FONT class='d'>●</FONT> <a href='UploadFile/"&rs("D_SaveFileName")&"' Target='_blank' title='"&rs("title")&"'>"&title&"</a> <img src='images/new.gif'></td>"
else
Response.Write "<td class='tdbgline' height='23'> <FONT class='d'>●</FONT> <a href='UploadFile/"&rs("D_SaveFileName")&"' Target='_blank' title='"&rs("title")&"'>"&title&"</a></td>"
end if
If js Mod 2 = 1 Then Response.Write "</tr>"
If js = rs.RecordCount-1 And js Mod 2 = 0 Then
Response.Write "<td> </td></tr>"
End If
end if
sid=rs("submenuid")
js = js + 1
js = rs.recordCount
rs.movenext
next

28,406

社区成员

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

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