仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1414|回复: 19
打印 上一主题 下一主题

[学习教程] ASP网页编程之若何轻松打造ASP计数器

[复制链接]
山那边是海 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-2-3 23:42:31 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
asp,你就只能等着微软给你解决,它不乐意你就只好悲催。而且asp跑在windows服务器上,windows服务器跟linux比起来简直弱爆了!计数器|计数器   以下引见用数据库完成复杂计数器
'上面存为count.asp
<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open "driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath("count.mdb")
%>
<%on error resume next%>
<%sql="update count set hit=hit+1%><%conn.Execute(sql)%>
<%sql = "select * from count
set rs=conn.execute(sql)
%>
<%
'更新每周逐日数据
lasthit=rs("lasthit")
tdate=year(Now()) & "-" & month(Now()) & "-" & day(Now())
if trim(lasthit)=trim(tdate) then
sql="update site set dayhit=dayhit+1 where id="&request("id")
conn.Execute(sql)
' response.write "success"
else
sql="update site set dayhit=1 where id="&request("id")
conn.Execute(sql)
' response.write "error"
end if
sql="update site set lasthit='"&tdate&"' where ID="&request("id")
conn.Execute(sql)

p_year=CInt(year(Now()))-CInt(year(lasthit))
p_month=CInt(month(Now()))-CInt(month(lasthit))
p_day=CInt(day(Now()))-CInt(day(lasthit))
period_time=((p_year*12+p_month)*30+p_day)
if cint(period_time)=<cint(7) then
sql="update site set weekhit=weekhit+1 where id="&request("id")
conn.Execute(sql)
else
sql="update site set weekhit=1 where id="&request("id")
conn.Execute(sql)
end if
%>
document.write('<tr><td width="100%">昔日会见<%=rs("dayhit")%>次,本周会见<%=rs("weekhit")%>次,总会见<%=rs("hit")%>次</td></tr>');
<%rs.close
set rs=nothing%>

'用<script language="JavaScript1.1" src="count.asp"></script>在要统计的页面挪用便可.
创立数据库:建一个count的MDB库,再建一个表count,表中字段为
hit 数字型
dayhit 数字型
weekhit 数字型
lasthit 日期型
</p>  写软件都是想的时间比写的时间要长的.如果反过来了就得看看是什么原因了. 另外大家可以回去问问公司里的小MM.(一般企业里,跟你们交付软件接触得最多的是她们)
山那边是海 该用户已被删除
沙发
 楼主| 发表于 2015-3-1 01:30:53 | 显示全部楼层
代码逻辑混乱,难于管理:由于ASP是脚本语言混合html编程,所以你很难看清代码的逻辑关系,并且随着程序的复杂性增加,使得代码的管理十分困难,甚至超出一个程序员所能达到的管理能力,从而造成出错或这样那样的问题。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-15 10:40

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表