Home  >  Article  >  Backend Development  >  PHP system traffic analysis program_PHP tutorial

PHP system traffic analysis program_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:07:13908browse

>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 homepage has been viewed so far
$query="select SUM(visits) as tvisits from stream";
$result=mysql_db_query('ajax',$query,$mlink);

echo 'Total cumulative number of visits to the homepage:';
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()-24*3600*$i;
$ctime2=time()-24*3600*($i-1);
echo 'Date:'.date("m月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,0,date(m,$ctime2),date(d,$ctime2),date(Y,$ctime2));
//Count the cumulative number of times the homepage was viewed on that day
$query='select SUM(visits) as tvisits from stream where sTime>=';
$query.=$stoday1.' and sTime<'.$stoday2;
$result=mysql_db_query('ajax',$query,$mlink ;
}
//Count the number of IP visits on the 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 number of viewers:".mysql_num_rows($result);
echo '


';
echo '';
echo '


';
echo "";

while($row=mysql_fetch_object($result)){
echo '';
echo '< td nowrap>'.$row->ip.'';
echo '';
echo '';
echo '';
echo " ";
}
echo "
IP addressLatest timeTimesUser information
'.date("h:i:sa",$row->sTime). ''.$row->visits.''.$row- >info.'
";
echo '
';
}
mysql_close($mlink);
?>





http://www.bkjia.com/PHPjc/315149.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/315149.htmlTechArticlecreate table stream (ip text, sTime int, visits int, info text); ? if($day0)$ day=0; $mlink=mysql_connect('localhost','ajax','xxxxxxx'); //Count the total number of times the homepage has been viewed so far$q...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn