kev wood Posted June 2, 2008 Share Posted June 2, 2008 is it possible to have a number stored in a db and instead of updating the table with a new number can you get it to ad the numbers together without first extracting the number from the db. if i unclear in what i am trying to ask please let me know i will explain in more detail. Quote Link to comment Share on other sites More sharing options...
trq Posted June 2, 2008 Share Posted June 2, 2008 Does this help? UPDATE num = num+1 WHERE id = 30; Quote Link to comment Share on other sites More sharing options...
kev wood Posted June 2, 2008 Author Share Posted June 2, 2008 that would just add one to the number stored would it not. i have count running which is stored in the mysql db. i only want the user to be able to perform a task so many times in one day. so each time the user logs on a does this action x amount of time i want this number to be added to the number already stored in the db so there is a running total of how many times the action has been completed. Quote Link to comment Share on other sites More sharing options...
trq Posted June 2, 2008 Share Posted June 2, 2008 So add whatever you need. eg; UPDATE num = num+40 WHERE id = 30; Quote Link to comment Share on other sites More sharing options...
kev wood Posted June 2, 2008 Author Share Posted June 2, 2008 i will not no the numbers that need to be added. could this code be written like this mysql_query("UPDATE email_count SET sent_messages = sent_messages+ $i") Quote Link to comment Share on other sites More sharing options...
trq Posted June 2, 2008 Share Posted June 2, 2008 Of course. sql queries are simply strings, like any other. Quote Link to comment Share on other sites More sharing options...
kev wood Posted June 2, 2008 Author Share Posted June 2, 2008 thank you for your help. i will click solved if it works Quote Link to comment 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.