一般的网页计数器制作实现思路:
首先设定存放统计数据的文件(counter.txt)
——读取文件中的内容存入字符串
——自加操作
——以写入方式打开文件写入数据
——从文件中输出统计数据
——关闭文件。
代码:
计数: 5
一、不限IP统计方式即只要刷新页面统计数就会增加
实现思路:首先设定存放统计数据的文件(counter[i].txt)是动态获取的即可以实现多页面统计
——读取文件中的内容存入字符串
——自加操作
——以写入方式打开文件写入数据
——从文件中输出统计数据
——关闭文件。
代码:
counter.php页面:
Warning: Use of undefined constant id - assumed 'id' (this will throw an Error in a future version of PHP) in D:\share\phpstudy_pro\www\test\counter_code.php on line 51
计数: 6
二、限IP统计方式即只有不同ip访问才会被记录为统计
实现思路:首先设定存放统计数据的文件(counter[i].txt)是动态获取的即可以实现多页面统计
——在设定存放统计ip数据的文件(ip[i].txt)是动态获取的
——读取文件中的内容存入字符串
——比较获取的ip是否已经存在于ip文件中,未存在重新写入自加操作
——更新ip
——以写入方式打开文件写入数据
——从文件中输出统计数据
——关闭文件。
counter_ip.php页面代码:
document.writeln('');
http://blog.163.com/dielianjun@126/blog/static/16425011320104204538143/
http://www.92csz.com/26/570.html
----------------------------------------------------------------------------------------------------------
mysql> create table tl(id integer(2),count integer(5));
Fatal error: Uncaught Error: Call to undefined function mysql_query() in D:\share\phpstudy_pro\www\test\counter_code.php:118
Stack trace:
#0 {main}
thrown in D:\share\phpstudy_pro\www\test\counter_code.php on line 118