static.htm
<html>
<head>
<title>在静态页面中显示文章被阅读的次数-测试</title>
</head>
<body>
<script src="counter.asp?id=1"></script>
</body>
</html>
counter.asp
<%
dim conn,hits
set conn = server.CreateObject("ADODB.Connection")
Connstr="driver={SQL Server};server=(local); uid=sa; pwd=;database=test"
conn.Open Connstr
dim id
id = request.QueryString("id")
'给文章点击数加1
sqlStr="update static set Hits=Hits+1 where id=" & id
conn.Execute sqlStr
'读出文章点击数
hits=conn.execute("select hits from static where id=" & id)(0)
%>
document.write(<%=hits%>)
本文介绍了一个简单的ASP脚本实现方式,用于更新并显示一个静态网页上特定文章的阅读次数。通过使用ADO对象与SQL Server数据库交互,实现了点击数的递增及读取功能。
1024

被折叠的 条评论
为什么被折叠?



