kramerkeller Posted March 13, 2007 Share Posted March 13, 2007 This is an embarrasingly easy question. So, I have a site and each time a particular page is viewed or an action called I simply want to increase a page count or action count in MySQL. Is there a simpler way than pulling the count from MySQL and then adding one and then restoring? I am not sure if there is some type of counter function or a way to update +1. Any help would be great. Quote Link to comment https://forums.phpfreaks.com/topic/42507-newb-question-mysql-counter/ Share on other sites More sharing options...
fenway Posted March 13, 2007 Share Posted March 13, 2007 So you basically want a hit counter... there are fancy ways to do this with auto_increment, actually, but a simple update statement works too. Quote Link to comment https://forums.phpfreaks.com/topic/42507-newb-question-mysql-counter/#findComment-206285 Share on other sites More sharing options...
kramerkeller Posted March 13, 2007 Author Share Posted March 13, 2007 so is the actual code i would use update `prospect_stats` set edits = '+1' where prospect_id = '$prospect_id'; how do I get the category 'edits' to increase by one everytime I want to update it? Sorry, again I am a super newb Quote Link to comment https://forums.phpfreaks.com/topic/42507-newb-question-mysql-counter/#findComment-206321 Share on other sites More sharing options...
fenway Posted March 13, 2007 Share Posted March 13, 2007 Close... update `prospect_stats` set edits = edits +1 where prospect_id = '$prospect_id' Quote Link to comment https://forums.phpfreaks.com/topic/42507-newb-question-mysql-counter/#findComment-206337 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.