news_index.asp

来自「我们的课程设计是一个工资管理系统」· ASP 代码 · 共 47 行

ASP
47
字号
<!--#include file="conn.asp" -->
<% 
dim times,topic
sql = " select  top 7 * from news order by datetime desc "
set rs = Server.CreateObject("Adodb.Recordset")
rs.open sql,conn,0,1
dim rstype
dim newstype
function gettype()
set rstype = conn.execute("select * from type where id="&rs("type")&"")
newstype = rstype("type")
rstype.close
set rstype = nothing
Response.Write(newstype)
end function
 %>
<html>
<head>
<link href="home.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="94%" border="0" align="center" cellpadding="0" cellspacing="0">
  <%
   do while not rs.eof
   times = cstr(year(rs("datetime"))) + "年" + cstr(month(rs("datetime"))) + "月" + cstr(day(rs("datetime"))) +  "日"
   if len(rs("topic"))>=18 then
   topic=left(rs("topic"),16)+".."
   else
   topic=rs("topic")
   end if   
   %>
  <tr> 
    <td height="25" colspan="2" valign="middle">[<%= gettype() %>]<a target="_blank" href="detail.asp?id=<%= rs("id") %>&ntype=<%= rs("type") %>" target="_parent"><%= topic %></a>[<%= times %>]</td>
  </tr>
  <%
  rs.movenext
  loop
  rs.close
  set rs = nothing
  closedatabase
  %>
</table>

</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?