shedcade Posted July 17, 2012 Share Posted July 17, 2012 Hi all, I've run into a bit of a problem, I'm producing some stats based on a football/soccer league table. I'm determining an individuals last ten results to output a form guide Won, Lost, Drawn, etc. However i would like to take this form and add up the equivalent points total for the last ten games. I am determining how to show my WLD record using the following part, which works great and i've now added in a points equivalent for each result. if ($scores_list['user_id_1_score'] > $scores_list['user_id_2_score'] && $scores_list['user_id_1'] == $imageleader['LINK']) { $win = 'W'; $pts = '3'; } elseif ($scores_list['user_id_1_score'] > $scores_list['user_id_2_score'] && ($scores_list['user_id_2'] == $imageleader['LINK'])) { $win = 'L'; $pts = '0';} elseif ($scores_list['user_id_1_score'] == $scores_list['user_id_2_score'] && ($scores_list['user_id_1'] == $imageleader['LINK'])) { $win = 'D'; $pts = '1';} elseif ($scores_list['user_id_1_score'] == $scores_list['user_id_2_score'] && ($scores_list['user_id_2'] == $imageleader['LINK'])) { $win = 'D'; $pts = '1';} elseif ($scores_list['user_id_1_score'] < $scores_list['user_id_2_score'] && ($scores_list['user_id_2'] == $imageleader['LINK'])) { $win = 'W'; $pts = '3';} elseif ($scores_list['user_id_1_score'] < $scores_list['user_id_2_score'] && ($scores_list['user_id_1'] == $imageleader['LINK'])) { $win = 'L'; $pts = '0'; } If i output the $pts i see the last ten games points equivalent, e.g. 3310013300 What i need to be able to do is get the total of these figures? Can it be done? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/265824-help-with-sum/ Share on other sites More sharing options...
ManiacDan Posted July 17, 2012 Share Posted July 17, 2012 Make a new variable called $total. $total += $pts; You could also make an array for $total, so it can hold the points for each team. Quote Link to comment https://forums.phpfreaks.com/topic/265824-help-with-sum/#findComment-1362243 Share on other sites More sharing options...
Barand Posted July 17, 2012 Share Posted July 17, 2012 this thread may be of interest http://forums.phpfreaks.com/index.php?topic=362277.0 Quote Link to comment https://forums.phpfreaks.com/topic/265824-help-with-sum/#findComment-1362259 Share on other sites More sharing options...
shedcade Posted July 20, 2012 Author Share Posted July 20, 2012 Fantastic, thank you both - working great! Quote Link to comment https://forums.phpfreaks.com/topic/265824-help-with-sum/#findComment-1362968 Share on other sites More sharing options...
MargateSteve Posted July 20, 2012 Share Posted July 20, 2012 Hi shedcade Purely out of curiosity, what is '== $imageleader['LINK']' referencing? The only reason I ask is I created a Current Form table (http://www.margate-fc.com/content/1st_team/cform.php?season_id=105), as well as standard, home and away tables and a stack of other football stats, for a site a couple of years back and am just about to start a rewrite of the entire code, so wondered if it is anything that I can use to improve my functionality. If there is anything else football stat related that you are looking to do, I might, be able to help. I am no php genius but as a lot of what I have done has come from advice on here, it can't be too bad!!! Thanks Steve Quote Link to comment https://forums.phpfreaks.com/topic/265824-help-with-sum/#findComment-1363134 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.