thinkphp实现文章访问量计数器
2016-08-08 16:40
155 查看
原理:每次刷新页面,执行一次某函数,某函数将数据表中的hit字段+1
不足:每次刷新,每次加1。
IndexController.class.php代码如下
showInfo.html代码如下
顺便附上index.html传id的代码
本文地址:http://liuyanzhao.com/3488.html
转载请注明
不足:每次刷新,每次加1。
IndexController.class.php代码如下
public function showInfo(){ $id = $_GET['id']; //当点击文章标题,展开文章全文页面,传过去id $info = M('Info'); $info->where(array('id' => $id))->setInc('hit',1);//hit字段+1 $arr=$info->find($id); //在showInfo.html输出 $this->assign('data',$arr); $this->display(); }
showInfo.html代码如下
{$data.hit}
顺便附上index.html传id的代码
<a href="__URL__/showInfo/id/{$vo.id}" >{$vo.info_title}</a>
本文地址:http://liuyanzhao.com/3488.html
转载请注明
相关文章推荐
- 调用WordPress函数统计文章访问量及PHP原生计数器的实现
- 调用WordPress函数统计文章访问量及PHP原生计数器的实现
- MySQL中实现高性能高并发计数器方案(例如文章点击数)
- ASP Access实现网站计数器(访问量)
- Thinkphp-实现文章回收站的功能
- 夺命雷公狗ThinkPHP项目之----企业网站12之文章添加的实现
- ThinkPHP实现文章上一篇和下一篇
- MySQL中实现高性能高并发计数器方案(例如文章点击数)
- 在ThinkPHP3.x框架中实现将原创文章第一时间推送到百度收录
- Thinkphp下文章管理系统icon图标功能的实现
- Thinkphp发布文章获取第一张图片为缩略图实现方法
- ASP Access实现网站计数器(访问量)
- 看到一篇文章刷CSDN博客访问量,目前没有环境实现,抽空可以去跑跑看或者改为其他方式实现
- 记一次实现统计访问量最高文章的功能
- 夺命雷公狗ThinkPHP项目之----企业网站13之文章列表页的实现(主要是分页的实现)
- 实现QQ窗体的缩入伸出功能(文章来自csdn) 选择自 lovecdw 的 Blog
- >+ 后台文章管理的一些基本功能及实现方法
- 用正则表达式实现对文章内容的查找