敬业的IT人 >> 网站建设 >> Web编程 >> Asp >> 用多种方法制作WEB页面的计数器

用多种方法制作WEB页面的计数器

敬业的IT人 互联网 佚名 2008-4-14 16:53:05
One way to do it:

Do you like to know how many users visited your site? Creating a Web counter is very easy thing to do
using ASP. The%>
<HTML>
<HEAD>
<TITLE>Counter Example 1</TITLE>
</HEAD>
<BODY>
<H1> You are the visitor number <%=Application("count")%></H1>
</BODY>
</HTML>



Another way to do it:

Ok that’s very nice, but what will happen if the application stops for any reason? You will lose all the
data stored in the application variables and that includes the count variable. To solve this problem I
will use another way, you need to store the value of the count variable with in a text file or database.
For me I prefer database so I will use an MS access(小型网站之最爱) database with a table ofcounter.mdb"))
Connection.Open ConStr

' Create the record set and retrive the counter value
Set RS = Connection.Execute("SELECT * FROM count")

' Increase the counter value bycontentad">
and when a session ends we will decrease it by RUNAT="Server">

Sub Application_OnStart
         'Create the variable that will hold the number of active visitors
    Application("Active") = 0
End Sub

Sub Session_OnStart
   'Increase the counter by>
粤ICP备06119539号
Copyright CiscoSky.Org,Some Rights Reserved.
Email:me1228#tom.com