给纸带过滤机网站 添加了个提取数据库首页添加新闻展示代码,提取最最后写出的的6条新闻,怎么觉得这么丑,这么笨呢?贴出来给大家看看,像我这等大白菜也只能这样做了,高手给个指点,更菜的可以学习。哈哈。
<%
sql = "select top 1 id,title from news order by id desc" '倒序输出
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
title1 = rs("title")
id1 = rs("id")
sql = "select top 1 id,title from news where id<"&id1 &" order by id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
title2 = rs("title")
id2 = rs("id")
sql = "select top 1 id,title from news where id<"&id2 &" order by id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
title3 = rs("title")
id3 = rs("id")
sql = "select top 1 id,title from news where id<"&id3 &" order by id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
title4 = rs("title")
id4 = rs("id")
sql = "select top 1 id,title from news where id<"&id4 &" order by id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
title5 = rs("title")
id5 = rs("id")
sql = "select top 1 id,title from news where id<"&id5 &" order by id desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
title6 = rs("title")
id6 = rs("id")
rs.close
set rs=nothing
%>
<tr> '其实tr里边可以加marquee动态输出以下的文字,挺好看的。
新闻展示:
<a href="/news.asp?id=<% =id1 %> " > <% =title1 %></a>
<a href="/news.asp?id=<% =id2 %> " > <% =title2 %></a>
<a href="/news.asp?id=<% =id3 %> " > <% =title3 %></a>
<a href="/news.asp?id=<% =id4 %> " > <% =title4 %></a>
<a href="/news.asp?id=<% =id5 %> " > <% =title5 %></a>
<a href="/news.asp?id=<% =id6 %> " > <% =title6 %></a>
</tr>
'这一堆真够长的,本来用了个数组,还有for语句,但怎么也没搞好,哎菜呀,新手就这样。^_^
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。
admin 于 2011-12-28 11:02:57 回复自吹自擂