search
Homephp教程php手册thinkPHP下简单的网站访问量统计

thinkPHP下的网页简单访问量统计
mysql代码

create table count(
ip int(10) primary key not null auto_increment,
nowdate varchar(255),
nowdatec varchar(255)

)



thinkPHP控制器代码


public function count(){
ini_set('date.timezone','Asia/Shanghai');
$date=date('Y-m-d');
$yesterday=date("Y-m-d",strtotime("-1 day"));
$yesterdayc=M('count')->getfieldbynowdate($yesterday,'nowdatec');
$row=M('count')->where('nowdate="'.$date.'"')->select();
$n=1;
$add=array(
'nowdatec'=>$n,
'nowdate'=>$date,
);


if(empty($row)){
M('count')->add($add);
}
$row1=M('count')->field('nowdatec')->where('nowdate="'.$date.'"')->select();


foreach($row1 as $cd){
$dd= $cd['nowdatec'];
}




echo '今天访问量:',$dd,'';

$dd+=1;
$now=array(
'nowdatec'=>$dd,

'nowdate'=>$date,
);
M('count')->where('nowdate="'.$date.'"')->save($now);
$rows=M('count')->field('nowdatec')->select();
$sun=0;
for ($i=0;$i $sun+=$rows[$i]['nowdatec'];
}

if(!empty($yesterdayc)){
echo '昨天访问量:',$yesterdayc,'';
}else{
echo '昨天访问量:0';
}

if(!empty($sun)){
echo '总访问量:',$sun,'';
}else{
echo '总访问量:0';
}


}

AD:真正免费,域名+虚机+企业邮箱=0元

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment