新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
php怎么實(shí)現(xiàn)前端統(tǒng)計(jì)流量
本文操作環(huán)境:Windows7系統(tǒng),php7.1版,Dell G3電腦。

目前創(chuàng)新互聯(lián)已為上1000家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬主機(jī)、網(wǎng)站改版維護(hù)、企業(yè)網(wǎng)站設(shè)計(jì)、鋼城網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
php 怎么實(shí)現(xiàn)前端統(tǒng)計(jì)流量?
php流量統(tǒng)計(jì)功能的實(shí)現(xiàn)代碼
用php實(shí)現(xiàn)的流量統(tǒng)計(jì)功能代碼,本代碼僅供學(xué)習(xí)交流,其中必有不妥之處。
流量統(tǒng)計(jì)功能
顯示效果:
總訪問量:399 今日流量:14 昨日流量:16
-- -- 表的結(jié)構(gòu) `mycounter` -- CREATE TABLE `mycounter` ( `id` int(11) NOT NULL auto_increment, `Counter` int(11) NOT NULL, `CounterLastDay` int(10) default NULL, `CounterToday` int(10) default NULL, `RecordDate` date NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=gbk AUTO_INCREMENT=2 ;
函數(shù)過程如下:
$RecordDate_explode[0]) $IsGone = TRUE;
else if( $DateNow_explode[0] == $RecordDate_explode[0] ){
if( $DateNow_explode[1] > $RecordDate_explode[1] ) $IsGone = TRUE;
else if( $DateNow_explode[1] == $RecordDate_explode[1] ){
if( $DateNow_explode[2] > $RecordDate_explode[2] ) $IsGone = TRUE;
}else BREAK; // www.jbxue.com
}else BREAK;
//根據(jù)IsGone進(jìn)行相應(yīng)操作
IF($IsGone) {
$RecordDate = $DateNow;
$CounterToday = 0;
$CounterLastDay = $row['CounterToday'];
$upd_sql = "update mycounter set RecordDate = '$RecordDate',CounterToday = '$CounterToday',CounterLastDay = '$CounterLastDay' WHERE id = ?' ";
mysql_query($upd_sql);
}
//再次獲取數(shù)據(jù)
$querysql = "SELECT * FROM `mycounter` WHERE id = ?' ";
$queryset = mysql_query($querysql);
$Counter = $row['Counter'];
$CounterToday = $row['CounterToday'];
$CounterLastDay = $row['CounterLastDay'];
if($row = mysql_fetch_array($queryset) ){
if( $_COOKIE["user"] != "oldGuest" ){
$Counter = ++$row['Counter'];
$CounterToday = ++$row['CounterToday'];
$upd_sql = "update mycounter set counter = '$Counter',CounterToday = '$CounterToday' WHERE id = ?' ";
$myquery = mysql_query($upd_sql);
}
echo "總訪問量:".$Counter;
echo "
";
echo "今日流量:".$CounterToday;
echo "
";
echo "昨日流量:".$CounterLastDay;
}else{//如果數(shù)據(jù)庫為空時,相應(yīng)的操作
}
}
?>
當(dāng)然,需要在文件第一行開始寫出如下代碼:
文章標(biāo)題:php怎么實(shí)現(xiàn)前端統(tǒng)計(jì)流量
文章URL:http://fisionsoft.com.cn/article/ccoijpi.html


咨詢
建站咨詢
