欢迎光临
我们一直在努力

asp进阶之文章在线管理更新(6)_asp实例

建站超值云服务器,限时71元/月

ASP进阶之文章在线管理更新–文章显示篇

作者:沙滩小子

  前面已经为大家介绍了文章的添加保存,接下来就应该讲讲文章的显示了。在这里,你更加可以看出ASP的简单易用性,仅仅是通过一个文件,就可以对数据库内的所有文章进行显示。它主要是通过从连接返回的文章号(articleid)和栏目的信息(typeid)来打开数据库中指定的记录以及指定显示所需要的内容。

  以下是文章显示页面(list.asp)的详细代码以及注解:

  "打开数据库连接
<!–#include file="conn.asp"–>
<html>
<%
  "定义变量
dim sql
dim rs
dim typename
dim typeid
dim rstype,typesql
  "接受返回的栏目信息并打开指定栏目记录集type
typeid=request("typeid")
set rstype=server.createobject("adodb.recordset")
  typesql="select * from type where typeID="&cstr(typeid)
  rstype.open typesql,conn,1,1
  "调用指定栏目名称并将其信息指定给typename
  typename=rstype("type")
  "关闭记录集
  rstype.close
%>
<head>
<title>ASP动网先锋|http://asky.on.net.cn</title>
<link rel="stylesheet" href="style.css">
</head>

<body>
<div align="center"><center>

<table border="1" width="97%" cellspacing="0" cellpadding="0" bordercolorlight="#000000"
bordercolordark="#FFFFFF">
  <tr>
    <td width="100%" bgcolor="#D0D0D0"><p align="center">
  "显示栏目信息
 栏目:<%=typename&%>
<%
  "打开指定记录集article,并通过返回的文章号id打开指定文章号的相关内容,在这里显示了文章号,加入日期,浏览数,文章标题以及文章内容
set rs=server.createobject("adodb.recordset")
sql="select * from artidle where articleid="&request("id")
rs.open sql,conn,1,1
%>
—-文章编号:<%=rs("articleid")%>—-加入日期:<%=rs("date")%>—-浏览数:<%=rs("hits")%></td>
  </tr>
  <tr>
    <td width="100%"><p align="right"><a href="javascript:self.close()">『关闭窗口』</a></td>
  </tr>
  <tr>
    <td width="100%"><p align="center"><b><%=rs("title")%></b></td>
  </tr>
  <tr>
    <td width="100%">
    <blockquote>
      <br>
<%=rs("content")%>      <br>
      <br>
<p align=center>
  "这里是文章的EMAIL转发,通过一段sentemail程序来实现,下面将为大家介绍
<form method=Post action=sentemail.asp?id=<%=rs("articleid")%>>
<b>发送文章到邮箱</b><br>
<input type=text name=email maxlength=20 class=smallInput>
  <input class=buttonface type=submit  value=发送  name=send>
</form>
    </blockquote>
   </td>
  </tr>
</table>
</center></div>
</body>
</html>
<%
  "关闭记录集和数据库连接
rs.close
set rs=nothing
conn.close
set conn=nothing
%>

  以上就是文章的显示程序,在这里以一段很少的代码就实现了从数据库调用指定文章内容以及显示的过程,相信到这里你更能体会到ASP的功用了,在本节中提到了利用ASP在线发送文章到信箱的程序,那么下面我将为大家介绍关于文章转发邮箱功能!

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » asp进阶之文章在线管理更新(6)_asp实例
分享到: 更多 (0)