简体   繁体   English

如何在PHP和MYSQL上保留博客文章计数器?

[英]How can I keep a blog post counter on PHP and MYSQL?

Is there a good way to keep track of page views for blog posts on a CMS on PHP? 有没有一种很好的方法来跟踪PHP CMS上博客文章的页面浏览量?

For instance would I track sessions? 例如,我会跟踪会话吗? Or Would I track Unique page views, etc. How would I check add that to each page without using google analytics if there is a robust library that is simple to use in either javascript, etc. 还是我可以跟踪唯一身份页面浏览量等。如果有一个健壮的库可以在javascript等中轻松使用,那么我将如何在不使用Google Analytics的情况下将其添加到每个页面。

Take a look at $_SERVER at http://php.net/manual/en/reserved.variables.server.php http://php.net/manual/zh/reserved.variables.server.php上查看$ _SERVER

You can grab a clients IP address using $_SERVER['REMOTE_ADDR'] and use a cookie or session to make sure you only store the "visit" once per unique IP address. 您可以使用$ _SERVER ['REMOTE_ADDR']获取客户​​端IP地址,并使用Cookie或会话来确保每个唯一IP地址仅存储一次“访问”。

Your counter would simply be a PHP query that did a count of all DISTINCT IP addresses found in your table. 您的计数器将只是一个PHP查询,该查询对表中找到的所有DISTINCT IP地址进行计数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修改tumblr bookmarklet以发布到特定的tumblr博客? - How can I modify the tumblr bookmarklet to post to a specific tumblr blog? 如何在 Mongoose 中更新博客文章? - How do I update blog post in Mongoose? 如何使计数器在指定日期不断增加到某个数字? - How can I make a counter keep increasing to a certain number on a specified date? 使用lodash我如何保持一个计数器,以后可以用作参数? - Using lodash how I can keep a counter that later could used as a parameter? 如何在博客博客中获取上一篇文章的日期并将其显示在另一个网站上? - How can I grab the date of the last post on my blogger blog and display it on another site? 如何使用文本预览在html / css / js中创建可扩展博客文章 - How can I create an expandable blog post in html/css/js with a text preview 为什么我不能左键单击我的博客文章? - Why i can't left click on my blog post? 如何在NodeJS中保持恒定的MySQL连接存活 - How can I keep a constant MySQL connection alive in NodeJS 如何在不使用AngularJS加载新页面的情况下让我的wordpress网站在同一页面上显示博客文章? - How can I get my wordpress site to show a blog post in the same page without loading a new page using AngularJS? 如何重用画廊中的特定功能到博客,以便在所有帖子的画廊视图和幻灯片视图中的特定帖子之间切换 - How can I reuse a specific function from a gallery to a blog to switch between gallery view of all posts and a specific post in slideshow view
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM