web建站教程
  1. 首页
  2. vuejs
  3. js
  4. 好玩
  5. seo教程
  6. 前端知识
  7. 百度echarts
  8. 更多
    php入门
    nodejs
    mockjs
    reactjs
    mysql
    wordpress
    织梦cms
    帝国cms
    git教程
    IT知识
    模板大全
    休息站

wordpress不用插件如何实现访客统计

523 ℃
     

wordpress不用插件如何实现访客统计,方法很简单,下面web建站小编给大家讲解一下步骤!

1、新建一个wp_count表

id
ip
times

2、建一个count.php文件

<?php 
//连接数据库 
$conn=mysql_connect("localhost","root","123456"); 
if(!$conn){ 
die("链接失败".mysql_errno()); 
} 
//设置数据库编码方式 
mysql_query("set names utf8",$conn) or die(mysql_errno()); 
//选择数据库 
mysql_select_db("wordpress",$conn) or die(mysql_errno()); 
$adress=$_SERVER["REMOTE_ADDR"]; 
//将本次访客的ip地址添加到数据库中 
$sql="select times from wp_count where ip='$adress'"; 
$res=mysql_query($sql,$conn); 
if(!$row=mysql_fetch_row($res)){ 
  $sql="insert into wp_count(ip, times) values('$adress','1')"; 
}else{ 
  $times = $row['0']+1; 
  $sql="update wp_count set times='$times' where ip='$adress'"; 
} 
$res=mysql_query($sql,$conn);
//发送语句获取总数 
$sql="select count(ip) from wp_count"; 
$res=mysql_query($sql,$conn); 
if($row=mysql_fetch_row($res)){ 
  $num=$row['0']; 
} 
echo"您是第 "."$num"." 位访客"."您的ip地址是"."$adress"; 
mysql_close(); 
?>

php如何实现单篇文章的访问量统计

标签: 访客统计

上面是“wordpress不用插件如何实现访客统计”的全面内容,想了解更多关于 wordpress 内容,请继续关注web建站教程。

当前网址:https://ipkd.cn/webs_2489.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

当前位置: 网站首页 > wordpress
本文共计821个字,预计阅读时长6分钟
生活小工具,收录了80多款小工具
上一篇: 推荐一个可以查询老黄历的网站,可以根据五行取名!
下一篇: 详细介绍HTTP状态码不同之处的原因(什么原因导致的)
x 打工人ai神器