TimUSA Posted January 7, 2008 Share Posted January 7, 2008 Hi again....i have googled this to death before coming here groveling for help again! i have this query: $query = "SELECT `skipperName` , `matchPoints` FROM `pts_table` GROUP BY `skipperName`;"; $result = mysql_query($query); if(mysql_num_rows($result)) { while($row = mysql_fetch_row($result)) { echo' <table> <tr> <left><td>' . $row[0] . '</td></left><br> <right><td><left>' . $row[1] . '</td></right><br> </tr> </table>'; } } What I would actually like to do is to GROUP BY `skipperName` and add the total value of all the `match` points for that column?? am i making sense? Quote Link to comment https://forums.phpfreaks.com/topic/84900-solved-sum-of-all-rows/ Share on other sites More sharing options...
revraz Posted January 7, 2008 Share Posted January 7, 2008 MySQL has a SUM function. Quote Link to comment https://forums.phpfreaks.com/topic/84900-solved-sum-of-all-rows/#findComment-432859 Share on other sites More sharing options...
jvrothjr Posted January 7, 2008 Share Posted January 7, 2008 $query = "SELECT skipperName, sum(matchPoints) as SummatchPoints FROM pts_table GROUP BY skipperName;"; $result = mysql_query($query); if(mysql_num_rows($result)) { while($row = mysql_fetch_row($result)) { echo' <table> <tr> <left><td>' . $row[skipperName] . '</td></left><br> <right><td><left>' . $row[summatchPoints] . '</td></right><br> </tr> </table>'; } } Quote Link to comment https://forums.phpfreaks.com/topic/84900-solved-sum-of-all-rows/#findComment-432860 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.