Access Statistics Program (two program)

Source: Internet
Author: User
Program | access | statistics/*
Original: Tofu
Please keep this message when you reprint and use it.
*/
/* dbcn.asp
To create a common program for a database connection
*/
<%
function Openconn ()
' Create a database connection
Dim connstr
Dim uid
Dim pwd
Dim db
Uid= "BBC"
Pwd= "BBC"
db= "BBC"
Softserver= "Softdepserver"
Set Conn = Server.CreateObject ("ADODB. Connection ")
Connstr= "Provider=SQLOLEDB.1; Uid= "& uid &"; Pwd= "& PWD &";d atabase= "& db &"; server= "& Softserver &" "

Conn.Open ConnStr

Set Openconn=conn
End Function

function Openrst ()
' Create a database record set
Set Rst=server.createobject ("ADODB. Recordset ")
Set Openrst=rst
End Function
%>
/*
Staticfunc
The function library that the statistic program needs to use
*/
<!--#include file= "dbcn.asp"-->
<%
Set Conn=openconn ()
Set Rst=openrst ()
Sub Writedatetable (Intstart,intend,strarray,ccount)
' Generate statistics
%>
<table border=1 width=100%>
<%for i= Intstart to Intend%>
<tr>
&LT;TD Width=30%><%=strarray (i)%></td>
&LT;TD width=60%>
<%
If Rst.eof Then
Setbar 0,ccount
Else
If RST (1) =i Then
Setbar rst (3), ccount
If not rst.eof then Rst.movenext
Else
Setbar 0,ccount
End If
End If
%>
</td>
</tr>
<%next%>
</table>
<%
End Sub
%>
<%
Sub Setbar (Num,ccount)
' Generate statistics Bar
If Ccount=0 Then
Percent=0
Else
Percent=cint (num/ccount*10000)/100
End If
strgif= "Bar.gif"
%>
<font color=red><%=percent%> %</font>
&LT;TD align=center>
<%=num%>
</td>
<%
End Sub
%>
<%
Sub Writedaystatic (userid)
' Generate Day statistics
I=0
Dim Strarray (100)
For I=0 to 23
Strarray (i) = CStr (i) & "Point-" & CStr (i+1) & "point"
Next
I=0
Set Rst=openrst ()
Strsql= "select sum (num) as ccount from datestatic where userid= '" & userid & ""
Rst.open strsql,conn,3,3
If IsNull (Rst ("Ccount")) Then
Ccount=0
Else
Ccount=rst ("Ccount")
End If
Strsql= "SELECT * from datestatic where userid= '" & userid & "ORDER by Hourid"
Set Rst=openrst ()
Rst.open strsql,conn,3,3
%>
Total Visits <%=ccount%>
<table border=1 width=100%>
<tr height=100%>
&LT;TD width=50%><% writedatetable 0, Strarray, ccount%></td>
<td width=50%><%writedatetable, Strarray, Ccount%></td>
</tr>
</table>
<%
End Sub
%>
<%
Sub Writeweekstatic (userid)
' Generate Week statistics
I=0
Dim Strarray (7)
Strarray (0) = "Sunday"
Strarray (1) = "Monday"
Strarray (2) = "Tuesday"
Strarray (3) = "Wednesday"
Strarray (4) = "Thursday"
Strarray (5) = "Friday"
Strarray (6) = "Saturday"
I=0
Strsql= "select sum (num) as ccount from weekstatic where userid= '" & userid & ""
Set Rst=openrst ()
Rst.open strsql,conn,3,3
If IsNull (Rst ("Ccount")) Then
Ccount=0
Else
Ccount=rst ("Ccount")
End If
Strsql= "SELECT * from weekstatic where userid= '" & userid & "ORDER by Dayid"
Set Rst=openrst ()
Rst.open strsql,conn,3,3
%>
Total Visits <%=ccount%>
<table border=1 width=100%>
<tr height=100%>
&LT;TD width=100%><% writedatetable 0



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.