【发布时间】:2011-06-21 19:09:08
【问题描述】:
1) 如何向 PHP 页面添加一个简单的页面计数器并将值插入 MySQL 表中?此外,我需要在每次新访问时更新 MySQL 表值。
2) 诀窍在于 PHP 页面是各种用户生成的登录页面的模板。例如,我希望这些页面中的每一个都有自己独立的计数器:
examplesite.com/template.php?getvalue=bob
examplesite.com/template.php?getvalue=sam
examplesite.com/template.php?getvalue=samantha
我的印象是,如果我将计数器放在“template.php”文件中,那么它会将每个用户的所有访问次数加起来。我想要的输出是让每个用户只获得单个登录页面的计数。
所以,如果总共有12次访问,分布如下:
examplesite.com/template.php?getvalue=bob had 4 visits
examplesite.com/template.php?getvalue=sam had 2 visits
examplesite.com/template.php?getvalue=samantha had 6 visits
那么我希望 bob 的页面计数器读取为“4”,sam 读取为“2”,samantha 读取为“6”。我是否正确假设如果我只是将计数器放在 template.php 上,每个用户的登录页面将读取为“12”?您有解决此问题的简单方法吗?
【问题讨论】: