PHP/SQL 单页浏览量计数器
嘿伙计们,我几个小时以来一直在寻找一个好的答案,但找不到我要找的东西!
如果我有一个动态网站(也许是新闻),我会得到以下链接
../domain.com/?newsid=1
../domain.com/?newsid=2
../domain.com/?newsid=3 等..
现在我将为每个页面都有一个单独的计数器..
因此,我会检查每个访问者,如果有人阅读“新闻 1”20 次,那么它也应该只算 1 次。 =>也许使用 IP 或 Cookie。
它应该是一个我可以包含在 php 代码中的函数,例如
我从来没有想过这样的事情。希望有人可以帮助我并给我一些提示如何编写这样的脚本(我是 php 新手顺便说一句)
Hey guys, I was looking for a good answer some hours now but can't find what I'm looking for!
If I have a dynamic Website (maybe news) I got the following links
../domain.com/?newsid=1
../domain.com/?newsid=2
../domain.com/?newsid=3 etc..
now I would have a individual counter for each of this page..
So I would check every single visitor and if someone is reading the "news 1" 20 times it also should count only 1 time. => Maybe with IP or Cookie.
It should be a function that I can include into the php code like <? pageviews(ID)?>
I never thougth anything like this. Hope someone can help me and give me some tips how I can code a script like this (I'm php newbie btw)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该考虑在新闻表中使用计数器字段,例如,当有人打开 ?newsid=1 时,您可以执行以下操作:
You should consider using a counter field in your news table such that when someone opens ?newsid=1 for example, you do this:
我在 http:// /talkerscode.com/webtricks/create-a-simple-pageviews-counter-using-php-and-mysql.php 让我简短地创建一个包含行数和页面的表,然后编写此代码
i found a great article on http://talkerscode.com/webtricks/create-a-simple-pageviews-counter-using-php-and-mysql.php let me short the code create a table with rows count and page and then write this code