glenna1984 Posted January 2, 2008 Share Posted January 2, 2008 I have a table that looks like: A int(1) B int(1) C int(1) total int(2) In my php code I want to put a line that will update the field total as the sum of A + B + C I know it is simple, but I cannot get seem to get it right. Thanks, Glenn Quote Link to comment https://forums.phpfreaks.com/topic/84205-sum-fields-in-php/ Share on other sites More sharing options...
trq Posted January 2, 2008 Share Posted January 2, 2008 UPDATE tbl SET total = a+b+c; Quote Link to comment https://forums.phpfreaks.com/topic/84205-sum-fields-in-php/#findComment-428778 Share on other sites More sharing options...
glenna1984 Posted January 2, 2008 Author Share Posted January 2, 2008 That works perfectly in mysql. To put that into a .php file, however, don't I need to add something like mysqlXXXX() ? Quote Link to comment https://forums.phpfreaks.com/topic/84205-sum-fields-in-php/#findComment-428806 Share on other sites More sharing options...
psychowolvesbane Posted January 2, 2008 Share Posted January 2, 2008 $SQL = "UPDATE tbl SET total = a+b+c"; $RSUpdate = mysql_query($sql,$conn); $conn is your MySQL connection queries. Quote Link to comment https://forums.phpfreaks.com/topic/84205-sum-fields-in-php/#findComment-428809 Share on other sites More sharing options...
glenna1984 Posted January 3, 2008 Author Share Posted January 3, 2008 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/84205-sum-fields-in-php/#findComment-428855 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.