ASP网页制作 怎么从数据库里调取最新文章题目,显示在网页里

来源:百度知道 编辑:UC知道 时间:2024/06/08 11:50:05
各位大侠,小弟初学ASP和数据库,基本不怎么明白
现在有段代码,从数据库里调取的最新的一条文章题目和一些文章内容,我想实现调取多几条文章题目,不用显示文章内容,应该怎么修改代码啊
现在得代码如下:
<!--#include file="Inc/conn.asp"-->
<head>
<title><%=SiteTitle%>|<%=SiteTitle2%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="<%=SitePath%>images/css4.css" type=text/css rel=stylesheet>
<%If rss=1 then%>
<%end if%>
</head>
<body>

<div class="mw" style="width: 197px; height: 16px">

<div class="topnews">
<%
set rs1=server.createobject("ADODB.Recordset")
sql1="select Top 1 ID,Title,Images,ArtDescription,TitleFontColor from Yao_Article where yn = 0 and IsTop = 1 and IsHot = 1 order by DateAndTime desc"
rs1.open sql1,conn,1,3

你查一下你的库,是不是你里面符合这种条件的记录只有两条

<%
set rs1=server.createobject("ADODB.Recordset")
sql1="select Top 5 ID,Title,Images,ArtDescription,TitleFontColor from Yao_Article where yn = 0 and IsTop = 1 and IsHot = 1 order by DateAndTime desc"
rs1.open sql1,conn,1,3
If Not rs1.Eof Then
do while not (rs1.eof or err)
%><h4><a href="<%=IIF(html=1,"List.asp?ID="&rs1("ID")&"","Html/?"&rs1("ID")&".html")%>" target=_blank><%If rs1("TitleFontColor")<>"" then Response.Write("<font style=""color:"&rs1("TitleFontColor")&""">") End if%><%=rs1("Title")%><%If rs1("TitleFontColor")<>"" then Response.Write("</font>") End if%></a></h4>

<%
rs1.movenext
loop
end if