- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 WordPress。我已经收集了每日浏览量(总浏览量和唯一浏览量),现在想查看某些页面的每月统计信息。我可以获得总体 View ,但在获得独特 View 时遇到问题。我做了以下操作:
$ids = '181,57,123';
$certainPageIds = explode(',', $ids);
foreach($certainPageIds as $id){
$uniqueViews = $wpdb->get_results("SELECT distinct IP as all_uniques,
DATE_FORMAT( insertion_date, '%b' ) as month_name, DATE_FORMAT( insertion_date,
'%Y-%M' ) as full_date FROM daily_unique_views WHERE page_id = '".$id."'");
if($uniqueViews){
$uniqueViewsEncodedArray = json_decode(json_encode($uniqueViews), True);
var_dump($uniqueViewsEncodedArray);
}
}
上面的数组返回以下内容:
array(2) {
[0]=>
array(3) {
["all_uniques"]=>
string(13) "111.11.11.111"
["month_name"]=>
string(3) "Dec"
["full_date"]=>
string(13) "2016-December"
}
[1]=>
array(3) {
["all_uniques"]=>
string(13) "22.222.222.22"
["month_name"]=>
string(3) "Dec"
["full_date"]=>
string(13) "2016-December"
}
}
array(2) {
[0]=>
array(3) {
["all_uniques"]=>
string(13) "111.11.11.111"
["month_name"]=>
string(3) "Nov"
["full_date"]=>
string(13) "2016-November"
}
[1]=>
array(3) {
["all_uniques"]=>
string(13) "111.11.11.111"
["month_name"]=>
string(3) "Dec"
["full_date"]=>
string(13) "2016-December"
}
[2]=>
array(3) {
["all_uniques"]=>
string(12) "33.333.3.333"
["month_name"]=>
string(3) "Dec"
["full_date"]=>
string(13) "2016-December"
}
}
array(1) {
[0]=>
array(3) {
["all_uniques"]=>
string(13) "111.11.11.111"
["month_name"]=>
string(3) "Oct"
["full_date"]=>
string(13) "2016-October"
}
}
因此它返回每个页面的每月独特 View 。但您会发现,111.11.11.111
出现了很多次。所以我 12 月的每个页面都有相同的 IP。但我需要每个月只计算一次相同的IP。我怎样才能达到这个目标?是否与现有结果有关或者应该用 sql 修复它?请问有什么想法吗?
最佳答案
您可以使用 cte(公共(public)表表达式),如下所示:
DECLARE @ips TABLE(
id int,
ip varchar(3),
month varchar(3)
)
INSERT INTO @ips VALUES (1,'ip1', 'jan')
INSERT INTO @ips VALUES (2,'ip2', 'jan')
INSERT INTO @ips VALUES (3,'ip1', 'feb')
INSERT INTO @ips VALUES (4,'ip2', 'feb')
INSERT INTO @ips VALUES (5, 'ip2', 'jan');
-- Define the CTE expression name and column list.
WITH cte_ips (ip, month)
AS
-- Define the CTE query.
(
SELECT ip, month FROM @ips
)
-- count the results
SELECT COUNT(DISTINCT ip), COUNT(ip), month FROM Cte_ips GROUP BY Month
-- Define the outer query referencing the CTE name.
SELECT COUNT(DISTINCT IP) AS UniqueIPs, COUNT(IP) AS TotalIPs, month FROM cte_ips
GROUP BY month
关于php - 获取特定页面 ID 的唯一访客计数 - php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41228039/
我正在尝试为访问者获取真实IP 当我在 php 中回显时,它为我获取了我的真实IP echo $_SERVER['REMOTE_ADDRESS']; 但是当我尝试在 jQuery 中执行此操作时: $
我目前正在尝试在 Antlr4 Visitor 的帮助下开发一个 JavaScript 编译器。我已经用 Java 实现了这个,但无法弄清楚如何在 JavaScript 中执行此操作。也许有人可以回答
跟踪有多少用户和 guest 在线的最佳方法是什么?我正在制作一个有趣和学习的论坛 现在,我在用户表中有 2 个字段,名为 is_online 和 last_access_time。 如果当前时间是
如何在 Magento 中获取访客 ID?我在管理中的“客户”>“ guest ”下看到它,但如何将其打印在前端的页面上? 我为老客户找到了这个: getId(); ?> 最佳答案 $visitorD
您好,我想为客人设置 session ,我编写了应该执行此操作的脚本,并且确实如此,但仅插入到表部分...我不知道为什么脚本不想设置 session ,如果他拥有所有信息。 最佳答案 在第二个查询中
我想通过继承扩展已声明的访问者,并让运行时环境搜索访问者的后代以执行正确的方法。我可以在 C# 中使用它,但我希望在 C++ 中使用它。我在 g++ 中尝试了以下代码,但未调用后代方法;仅调用基类的方
本文实例讲述了php获取指定(访客)IP所有信息(地址、邮政编码、国家、经纬度等)的方法。分享给大家供大家参考。具体如下: 调用方法非常简单。这个也需要数据库来支持。数据库中中文和拼音共存才可以。
我知道这可以在 mysql 中完成,但我希望将 IP 存储在 php 或文本文件中,这对我来说有点困难,因为我不太理解它。 $SESSION 是用来记录日志的,但是如何在点击 html 按钮后将其存储
我正在创建一个 friend 系统,当用户访问另一个用户的个人资料时,他们会看到一个添加 friend 选项,当他们访问自己的个人资料时,他们可以看到其他东西而不是添加 friend 选项,如 TOT
我在我的 Windows 7 机器上使用 VMware 播放器将 Ubuntu 作为 guest 操作系统运行。我遇到的问题是在 Ubuntu 机器上同步时钟。仅当我关闭 VMware 播放器并打开暂
我正在使用虚拟机管理程序。在此我有 DOM0 操作系统,它正在使用 ttyS08250串口驱动。 在此操作系统上,我正在运行一个设备管理器应用程序,该应用程序启动 DOMU 内核,该内核在 8250
我已经在使用 Hyper-V 的 Windows 10 主机系统上安装了 Ubuntu 18.04 作为 guest 系统,我想在全屏模式下使用 guest 系统。据我所知,要调整屏幕大小,我需要在增
MySQL 服务器上的访客数据库如下所示id 是主键整数类型,firstname 和 lastname 是文本类型,访客 id 是整数类型 id firstname lastname
我是一名优秀的程序员,十分优秀!