> 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> 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 '}
Mysql_close ($ mlink );
?>