输出显示 有高手给改下

yymzzl 2008-01-31 03:41:04

<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from "&GuTablePrefix&"_Sort order by SortID asc",conn,1,1
if err.number <> 0 then
response.write "数据库查询出错"
else
if rs.bof and rs.eof then
response.write "没有相关信息"
else
do while not rs.eof
%>


<TABLE style="BORDER-LEFT: #c8d8ef 1pt solid; BORDER-BOTTOM: #c8d8ef 1pt solid"
cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>

<TABLE style="BORDER-BOTTOM: #c8d8ef 1pt solid" cellSpacing=0
cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width=137 background=newinc/lanmu_01.jpg
height=21>
<FONT color=#ffffff><B>  <%=rs("SortName")%></B></FONT></TD>
<TD align=right>
<a href="Sort.asp?SortID=<%=rs("SortID")%>" class="LightgrayV12">更多……</A>         </TD></TR></TBODY></TABLE>
</TD></TR>

<TR>
<TD>
<TABLE style="BORDER-RIGHT: #c8d8ef 1pt solid" cellSpacing=0
cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width="5%"> </TD>

<TD vAlign=top>
<%
set SubRs=server.createobject("adodb.recordset")
ArticleTitleKB=23
SubRs.open "select top 8 "&GuTablePrefix&"_Article.ArticleID,"&GuTablePrefix&"_Article.ArticleTitle,"&GuTablePrefix&"_Article.SortID,"&GuTablePrefix&"_Article.AsSortID,"&GuTablePrefix&"_Article.ArticleShow,"&GuTablePrefix&"_Article.ArticleDate,"&GuTablePrefix&"_AsSort.AsSortName FROM "&GuTablePrefix&"_Article,"&GuTablePrefix&"_AsSort where "&GuTablePrefix&"_Article.ArticleShow='1' and "&GuTablePrefix&"_AsSort.SortID="&Rs("SortID")&" and "&GuTablePrefix&"_Article.SortID="&Rs("SortID")&" and "&GuTablePrefix&"_AsSort.AsSortID="&GuTablePrefix&"_Article.AsSortID order by "&GuTablePrefix&"_Article.ArticleDate desc,"&GuTablePrefix&"_Article.ArticleID desc",conn,1,1

if err.number <> 0 then
response.write "数据库查询出错"
else
if SubRs.bof and SubRs.eof then
response.write "没有相关信息"
else
do while not SubRs.eof
%>
<TABLE cellSpacing=1 cellPadding=1 width="100%" border=0>
<TBODY>
<TR>
<TD width="80%" height=20>· 
<A href="Read.asp?ID=<%=SubRs("ArticleID")%>" class="LightgrayV12" title="<%=SubRs("ArticleTitle")%>  <%=Subrs("ArticleDate")%>"><%=cutStr(Subrs("ArticleTitle"),ArticleTitleKB)%></A>

</TD>

<TD>
<font class="SilverV10">[<%=month(Subrs("ArticleDate"))%>-<%=day(Subrs("ArticleDate"))%>]</font>
</TD><br>

<%====================================================这里怎么改 才能显示出来我想要的表格 每个sort显示这样一个表格,显示一个后,换行显示另一个,这里实在是折腾不出来了 谢谢大家 !
SubRs.movenext
loop
end if
end if
SubRs.close
%>
================================================
</TR>

</TBODY></TABLE>
</TD></TR>
</TBODY></TABLE></TD>



</TR></TBODY></TABLE>

<%

end if
rs.close
%>

...全文
36 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
braveboy 2008-01-31
<% 
dim rsarray,total0,total1,i,tmp,colspan
colspan = 6 '设置每行6列
set rs = server.createObject("ADODB.RECORDSET")
sql = "select wm_classid,wm_name from WM_CompanySort2 where WM_Depth = 0"
rs.open sql ,conn,1,1
if not rs.eof then
rsarray = rs.getrows()
total0 = rs.recordcount
end if
rs.close
tmp = " <table> "
for i = 0 to total0 - 1 '外层循环
sql = "select wm_classid,wm_name from WM_CompanySort2 where WM_Depth = 1 and wm_parentid = "& rsarray(0,i)
tmp = tmp &" <tr> <td colspan='"& colspan &"'> "& rsarray(1,i) &" </td> </tr> "
rs.open sql,conn,1,1
total1 = 0
if not rs.oef then total1 = rs.recordcount '记录数
if total1 mod colspan <> 0 then total1 = (total1 \ colspan + 1)* colspan '补空列
for j = 0 to total1 - 1 '内层循环
if j mod colspan = 0 then tmp = tmp & "<tr>" '换行
tmp = tmp & "<td>"
if not rs.eof then
tmp = tmp & rs(1) rs.movenext
else
tmp = tmp & " "
end if
tmp = tmp & "</td>"
if j mod colspan = colspan - 1 then tmp = tmp & "</tr>"
next
rs.close
next
tmp = tmp & " </table> "
response.write tmp
tmp = 0
set rs= nothing
%>
回复
braveboy 2008-01-31
晕,你这东西看上去太乱了,给你这个表格双层循环,你参考改下吧
<%
dim rsarray,total0,total1,i,tmp,colspan
colspan = 6 '设置每行6列
set rs = server.createObject("ADODB.RECORDSET")
sql = "select wm_classid,wm_name from WM_CompanySort2 where WM_Depth = 0"
rs.open sql ,conn,1,1
if not rs.eof then
rsarray = rs.getrows()
total0 = rs.recordcount
end if
rs.close
tmp = " <table> "
for i = 0 to total0 - 1 '外层循环
sql = "select wm_classid,wm_name from WM_CompanySort2 where WM_Depth = 1 and wm_parentid = "& rsarray(0,i)
tmp = tmp &" <tr> <td colspan='"& colspan &"'> "& rsarray(1,i) &" </td> </tr> "
rs.open sql,conn,1,1
total1 = 0
if not rs.oef then total1 = rs.recordcount '记录数
if total1 mod colspan <> 0 then total1 = (total1 \ colspan + 1)* colspan '补空列
for j = 0 to total1 - 1 '内层循环
if j mod colspan = 0 then tmp = tmp & "<tr>" '换行
tmp = tmp & "<td>"
if not rs.eof then
tmp = tmp & rs(1) rs.movenext
else
tmp = tmp & " "
end if
tmp = tmp & "</td>"
if j mod colspan = colspan - 1 then tmp = tmp & "</tr>"
next
rs.close
next
tmp = tmp & " </table> "
response.write tmp
tmp = 0
set rs= nothing
%>
回复
第一个的rs的do while not少了loop..........


看你3条3角裤了,怎么发代码都不会发???
回复
强强联盟 2008-01-31
把你要循环的东西挑出来放在程序里其余的放在外面
回复
兔子党-连长 2008-01-31
代码太混乱

要明白: 循环处理的东西都是有规律的

你把 table 的起始标记放到do里面 ,结束标记放外边

怎么肯能显示?
回复
xiaojing7 2008-01-31
我低手,改不了.
只敢看看
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2008-01-31 03:41
社区公告
暂无公告