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 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; 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() ? 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. 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! Link to comment https://forums.phpfreaks.com/topic/84205-sum-fields-in-php/#findComment-428855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.