heldenbrau Posted November 16, 2010 Share Posted November 16, 2010 Is there a quick way to increment a value in a database. I want to count how many times users go to certain pages. So when somebody clicks the page, a php script connects to the database and adds 1 on to the number. The only way I know how to do it is to connect to the database, search the table for this page and get the number of times it is viewed, then update the table. So 2 queries, is there a way to do it in one? Quote Link to comment https://forums.phpfreaks.com/topic/218849-incrementing-value-in-database/ Share on other sites More sharing options...
ManiacDan Posted November 16, 2010 Share Posted November 16, 2010 UPDATE `yourTable` SET `yourField` = `yourField` + 1 WHERE `someId` = 123; -Dan Quote Link to comment https://forums.phpfreaks.com/topic/218849-incrementing-value-in-database/#findComment-1134988 Share on other sites More sharing options...
heldenbrau Posted November 16, 2010 Author Share Posted November 16, 2010 Thanks, sorted. Quote Link to comment https://forums.phpfreaks.com/topic/218849-incrementing-value-in-database/#findComment-1134995 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.