> Create Table stream (
IP text,
Stime int,
Visits int,
Info text );
<?
If ($ day <0) $ day = 0;
$ Mlink = mysql_connect ('localhost', 'ajax ', 'xxxxxxx ');
// Count the total number of times the home page has been browsed so far
$ Query = "select sum (visits) as tvisits from stream ";
$ Result = mysql_db_query ('ajax ', $ query, $ mlink );
Echo '<SPAN class = "ST1"> total times of browsing the home page :';
If ($ ROW = mysql_fetch_object ($ result )){
Echo $ row-> tvisits;
}
$ Week = array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday ");
For ($ I = 0; $ I <= $ day; $ I ++ ){
Echo '<p> ';
$ Ctime1 = Time ()-24x3600 * $ I;
$ Ctime2 = Time ()-24*3600 * ($ i-1 );
Echo '<SPAN class = "st4"> date:'. date ("m month D", $ ctime1). $ week [date ("W", $ ctime1)];
Echo "</span> ";
$ Stoday1 = mktime (0, 0, 0, date (M, $ ctime1), date (D, $ ctime1), date (Y, $ ctime1 ));
$ Stoday2 = mktime (0, 0, date (M, $ ctime2), date (D, $ ctime2), date (Y, $ ctime2 ));
// Count the total number of times the homepage is browsed on the current day
$ Query = 'select sum (visits) as tvisits from stream where stime> = ';
$ Query. = $ stoday1. 'and stime <'. $ stoday2;
$ Result = mysql_db_query ('ajax ', $ query, $ mlink );
Echo '<SPAN class = "st3"> accumulated times of browsing the home page :';
If ($ ROW = mysql_fetch_object ($ result )){
Echo $ row-> tvisits;
}
// Count the number of IP addresses visited on the current day
$ Query = 'select * From stream where stime> = '. $ stoday1;
$ Query. = 'and stime <'. $ stoday2. 'order by stime DESC ';
$ Result = mysql_db_query ('ajax ', $ query, $ mlink );
Echo"
Total browsing count: ". mysql_num_rows ($ result );
Echo '</span> <HR size = "1"> ';
Echo '<Table border = "0" width = "100%" cellspacing = "0" cellpadding = "2" class = "st3"> ';
Echo '<tr> <TD nowrap class = "st2"> ip address </TD>
<TD nowrap class = "st2"> last time </TD>
<TD nowrap class = "st2"> Times </TD>
<TD nowrap class = "st2"> User Information </TD> ';
Echo "</tr> ";
While ($ ROW = mysql_fetch_object ($ result )){
Echo '<tr> ';
Echo '<TD nowrap>'. $ row-> ip. '</TD> ';
Echo '<TD nowrap>'. date ("H: I: SA", $ row-> stime). '</TD> ';
Echo '<TD nowrap>'. $ row-> visits. '</TD> ';
Echo '<TD nowrap>'. $ row-> info. '</TD> ';
Echo "</tr> ";
}
Echo "</table> ";
Echo '<HR size = "1"> ';
}
Mysql_close ($ mlink );
?>