[英]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.