最近在学ASP我试这写了这个ASP程序但是在显示时就显一条记录!
我要请教的是怎样控制显示个数!比如我想显5个新闻记录!
以下是我写的ASP程序!!!
<%
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&server.mappath("data.mdb")
set conn=server.createobject("ADODB.CONNECTION")
conn.open connstr
function mytext(tempstr,tempwid)
if len(tempstr)>tempwid then
mytext=left(tempstr,tempwid)&"..."
else
mytext=tempstr
end if
end function
Sub CloseDataConn
If IsObject(Conn) Then:Conn.Close:Set Conn = Nothing:End If
End Sub
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新闻动态</title>
</head>
<body>
<table border="0" width="100%" id="table1">
<tr>
<td bgcolor="#FF0000">
<p align="center"><font color="#FFFF00">新闻动态</font></td>
</tr>
<tr>
<td>
<table border="0" width="100%" id="table2"><% sql="SELECT top 8 * from (SELECT * from yui where id=1 ORDER BY ID DESC)"
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write " <tr> <td >暂无新闻</td></tr>"
else
do while not rs.eof
%>
<tr>
<td width="44">
<img border="0" src="images/UNDO.GIF" width="18" height="18"></td>
<td><a href="news.asp?id=<%=rs("id")%>&id=<%=rs("id")%>" title="<%=rs("bt")%>" target="_blank"><span class="style6">·</span><%=left(rs("bt"),17)%> </a></td>
</tr> <%
rs.movenext
loop
end if
rs.close
set rs=nothing
%>
</table>
</td>
</tr>
</table>
</body>
</html>