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. Link to comment https://forums.phpfreaks.com/topic/108377-solved-mysql-question/ 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; Link to comment https://forums.phpfreaks.com/topic/108377-solved-mysql-question/#findComment-555585 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. Link to comment https://forums.phpfreaks.com/topic/108377-solved-mysql-question/#findComment-555589 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; Link to comment https://forums.phpfreaks.com/topic/108377-solved-mysql-question/#findComment-555597 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") Link to comment https://forums.phpfreaks.com/topic/108377-solved-mysql-question/#findComment-555598 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. Link to comment https://forums.phpfreaks.com/topic/108377-solved-mysql-question/#findComment-555599 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 Link to comment https://forums.phpfreaks.com/topic/108377-solved-mysql-question/#findComment-555602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.