Click here to Skip to main content
15,885,903 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

PHP
$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:

SQL
id date icon views news_title image


PHP
$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?
Posted
Comments
virang_21 8-Jan-15 0:05am    
your update query is missing where clause.
UPDATE articles SET views = views + 1 where id=$article_id
[no name] 8-Jan-15 0:18am    
wow. thank you so much for that man! Kudos!

1 solution

Try this :

$insertLog = "UPDATE articles SET views = views + 1  where id=$article_id";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900