How To Sum goals

4 posts by 2 authors in: Forums > CMS Builder
Last Post: October 24, 2013   (RSS)

hi have this code 

<?php
$totalGoalf = 0;
$matches = mysql_select('matches');

foreach ($matches as $matches) {
$totalGoalf += floatval($matches['goal_home']);
}


?><?php echo number_format($totalGoalf) ?>

but how can i limit result where to "team_a is XX and season is XX"

Ok solved :D

<?php 
$totalGoalf = 0; 
$matches = mysql_select('matches', "team_a = '1' AND season = " . intval($seasonRecord['num']));

foreach ($matches as $matches) { 
$totalGoalf += floatval($matches['goal_home']); 
}


?><?php echo number_format($totalGoalf) ?>

By Damon - October 24, 2013

Glad to see you solved it and thanks for shared the solution!  :)

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/