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>
<TD Width=30%><%=strarray (i)%></td>
<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>
<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%>
<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%>
<TD width=100%><% writedatetable 0