asp新闻列表分两列怎么写
下面是代码请高手帮忙解决一下,谢谢!<%i=0SetRs=server.createobject("adodb.recordset")Rs.source="selectt...
下面是代码 请高手帮忙解决一下,谢谢!
<%
i=0
Set Rs = server.createobject("adodb.recordset")
Rs.source = "select top 8 * from News where TreeName like '%家居资讯%' order by id desc "
Rs.open Rs.source,conn,1,1
Response.Write"<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' class='Index-Center3' id=DataList1 >"
if Rs.BOF then
response.write "<tr><td align='center'>暂无新闻动态!</td></tr>"
else
for i=1 to 8
if Rs.EOF or Rs.BOF then exit for
Newtitle=Rs("Newtitle")
if len(Newtitle)>26 then Newtitle=left(Newtitle,26)&"......"
Response.Write"<tr><td><TABLE cellSpacing=0 cellPadding=0 width=""100%"" background=img/sy_14-4.gif border=0><TBODY><TR><TD width=20 height=26><IMG height=7 src=""img/sy_14-3.gif"" width=7></TD><TD><DIV><a href='info.asp?id="&Rs("id")&"' target='_blank'><font size=2;>"&Newtitle&"</font></a></DIV></A></TD><TD width=60 align=center><font color='#999999'>"&Rs("AddTime")&"</font></TD></TR></TBODY></TABLE></td></tr>"
Rs.movenext
next
end if
Response.Write"</table>"
Rs.Close
set Rs=nothing
%> 展开
<%
i=0
Set Rs = server.createobject("adodb.recordset")
Rs.source = "select top 8 * from News where TreeName like '%家居资讯%' order by id desc "
Rs.open Rs.source,conn,1,1
Response.Write"<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' class='Index-Center3' id=DataList1 >"
if Rs.BOF then
response.write "<tr><td align='center'>暂无新闻动态!</td></tr>"
else
for i=1 to 8
if Rs.EOF or Rs.BOF then exit for
Newtitle=Rs("Newtitle")
if len(Newtitle)>26 then Newtitle=left(Newtitle,26)&"......"
Response.Write"<tr><td><TABLE cellSpacing=0 cellPadding=0 width=""100%"" background=img/sy_14-4.gif border=0><TBODY><TR><TD width=20 height=26><IMG height=7 src=""img/sy_14-3.gif"" width=7></TD><TD><DIV><a href='info.asp?id="&Rs("id")&"' target='_blank'><font size=2;>"&Newtitle&"</font></a></DIV></A></TD><TD width=60 align=center><font color='#999999'>"&Rs("AddTime")&"</font></TD></TR></TBODY></TABLE></td></tr>"
Rs.movenext
next
end if
Response.Write"</table>"
Rs.Close
set Rs=nothing
%> 展开
2个回答
展开全部
<%
i=0
Set Rs = server.createobject("adodb.recordset")
Rs.source = "select top 8 * from News where TreeName like '%家居资讯%' order by id desc "
Rs.open Rs.source,conn,1,1
Response.Write"<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' class='Index-Center3' id=DataList1 >"
if Rs.BOF then
response.write "<tr><td align='center'>暂无新闻动态!</td></tr><tr>"
else
j=0
for i=1 to 8
if Rs.EOF or Rs.BOF then exit for
Newtitle=Rs("Newtitle")
if len(Newtitle)>26 then Newtitle=left(Newtitle,26)&"......"
Response.Write"<td><TABLE cellSpacing=0 cellPadding=0 width=""100%"" background=img/sy_14-4.gif border=0><TBODY><TR><TD width=20 height=26><IMG height=7 src=""img/sy_14-3.gif"" width=7></TD><TD><DIV><a href='info.asp?id="&Rs("id")&"' target='_blank'><font size=2;>"&Newtitle&"</font></a></DIV></A></TD><TD width=60 align=center><font color='#999999'>"&Rs("AddTime")&"</font></TD></TR></TBODY></TABLE></td>"
j=j+1
if j mod 2 = 0 then response.Write "</tr><tr>"
Rs.movenext
next
end if
Response.Write"</tr></table>"
Rs.Close
set Rs=nothing
%>
加一个变量判断下就好了,还有就是把<tr><td>标签位置重新调一下!
谢谢采纳!
i=0
Set Rs = server.createobject("adodb.recordset")
Rs.source = "select top 8 * from News where TreeName like '%家居资讯%' order by id desc "
Rs.open Rs.source,conn,1,1
Response.Write"<table width='100%' border='0' cellspacing='0' cellpadding='0' align='center' class='Index-Center3' id=DataList1 >"
if Rs.BOF then
response.write "<tr><td align='center'>暂无新闻动态!</td></tr><tr>"
else
j=0
for i=1 to 8
if Rs.EOF or Rs.BOF then exit for
Newtitle=Rs("Newtitle")
if len(Newtitle)>26 then Newtitle=left(Newtitle,26)&"......"
Response.Write"<td><TABLE cellSpacing=0 cellPadding=0 width=""100%"" background=img/sy_14-4.gif border=0><TBODY><TR><TD width=20 height=26><IMG height=7 src=""img/sy_14-3.gif"" width=7></TD><TD><DIV><a href='info.asp?id="&Rs("id")&"' target='_blank'><font size=2;>"&Newtitle&"</font></a></DIV></A></TD><TD width=60 align=center><font color='#999999'>"&Rs("AddTime")&"</font></TD></TR></TBODY></TABLE></td>"
j=j+1
if j mod 2 = 0 then response.Write "</tr><tr>"
Rs.movenext
next
end if
Response.Write"</tr></table>"
Rs.Close
set Rs=nothing
%>
加一个变量判断下就好了,还有就是把<tr><td>标签位置重新调一下!
谢谢采纳!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询