Createtablestream (iptext, sTimeint, visitsint, infotext );? If ($ day0) $ day0; $ mlinkmysql_connect (localhost, ajax, xxxxxxx); total number of times the home page has been browsed so far $ queryselectSUM (visits) astvisitsfromstream; $ resultmysql_db_query (ajax, $ que> 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 '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'
';
$ Ctime1 = time ()-24X3600 * $ I;
$ Ctime2 = time ()-24*3600 * ($ i-1 );
Echo 'date: '. date ("m Month D", $ ctime1). $ week [date ("w", $ ctime1)];
Echo "";
$ 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 'cumulative number of homepage views :';
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'
';
Echo'
';Echo'
IP address |
Last time |
Times |
User information | ';Echo"
";While ($ row = mysql_fetch_object ($ result )){Echo'
';Echo'
'. $ Row-> ip .' | ';Echo'
'. Date ("h: I: sa", $ row-> sTime ).' | ';Echo'
'. $ Row-> visits .' | ';Echo'
'. $ Row-> info .' | ';Echo"
";}Echo"
";
Echo' ';
}
Mysql_close ($ mlink );
?>