dessolator Posted December 5, 2007 Share Posted December 5, 2007 How do I total up a column in php/mysql I need to total 2 columns up with about 30 values then create this if statement: if Yscore > Gscore echo "Y is the winner". Thanks, Ian Link to comment https://forums.phpfreaks.com/topic/80365-solved-how-to-total-up-a-database-column-in-phpmysql/ Share on other sites More sharing options...
revraz Posted December 5, 2007 Share Posted December 5, 2007 This may help http://www.tizag.com/mysqlTutorial/mysqlsum.php Link to comment https://forums.phpfreaks.com/topic/80365-solved-how-to-total-up-a-database-column-in-phpmysql/#findComment-407342 Share on other sites More sharing options...
pocobueno1388 Posted December 5, 2007 Share Posted December 5, 2007 <?php $query = mysql_query("SELECT SUM(fld1) as Yscore, SUM(fld2) as Gscore FROM table")or die(mysql_error()); $row = mysql_fetch_assoc($query); echo $row['Yscore']; echo $row['Gscore']; ?> Link to comment https://forums.phpfreaks.com/topic/80365-solved-how-to-total-up-a-database-column-in-phpmysql/#findComment-407352 Share on other sites More sharing options...
dessolator Posted December 5, 2007 Author Share Posted December 5, 2007 Thanks very much guys, much appreciated Link to comment https://forums.phpfreaks.com/topic/80365-solved-how-to-total-up-a-database-column-in-phpmysql/#findComment-407355 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.