更新单个列以进行计数 [英] updating a single column to count
本文介绍了更新单个列以进行计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿伙计们,我只是想让这个来计算页面浏览量,我有它的工作,但它更新了所有的`views`列,而不是我正在查看的实际文章。
$ insertLog = 更新文章SET views = views + 1;
mysql_query($ insertLog)或 die(' MySQL错误 - 无法插入日志。');
我的数据库里面的表格是:
id 日期图标查看news_title 图片
$ article_id = mysql_real_escape_string( $ _GET [' id']);
那么这与我为计数器分配一个id以更新指定列有关吗?
有什么想法吗?
解决方案
insertLog = 更新文章SET views = views + 1;
mysql_query(
insertLog)或 die('' MySQL错误 - 无法插入日志。');
我的数据库里面的表格是:
id 日期图标查看news_title 图片
< blockquote> article_id = mysql_real_escape_string(
Hey guys, I'm simply trying to get this to count the page views, which I have it working, but it updates all the `views` columns, rather than the actual article I'm viewing.
$insertLog = "UPDATE articles SET views = views + 1";
mysql_query($insertLog) or die('MySQL Error - Could not insert log.');
what I have in my table inside my database is:
id date icon views news_title image
$article_id = mysql_real_escape_string($_GET['id']);
So does it have something to do with me assigning an id to the counter to update that specified column?
Any ideas?
解决方案
insertLog = "UPDATE articles SET views = views + 1"; mysql_query(
insertLog) or die('MySQL Error - Could not insert log.');
what I have in my table inside my database is:
id date icon views news_title image
article_id = mysql_real_escape_string(
这篇关于更新单个列以进行计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文