kenny22 Posted February 3, 2011 Share Posted February 3, 2011 I'm in the process of creating a webage that shows latest scores and an updated league table for soccer/football matches like the bbc sports website does. I have the database set up with a form to update and display latest score all work well apart from if i update a score like the following teamA 1 teamB 0 it updates table to give teamA 3 points based on the current score however if teamA score again teamA 2 teamB 0 it updates table again but gives teamA another 3 points which is not correct so i need a way to stop it happening. thought about it for a while and only thing i can come up with is some maths to compare the values of score for each team and add/remove points as dependent on current score. Anyone got something similar to this Quote Link to comment https://forums.phpfreaks.com/topic/226568-help-with-creating-latest-score-table/ Share on other sites More sharing options...
ManiacDan Posted February 3, 2011 Share Posted February 3, 2011 Wait...in what country do soccer games score in 3-point intervals? Why are you claiming your queries will update the wrong way...or something. Show the queries you're running. Your WHERE clause should be identifying these games based on a unique identifier (either an auto-increment ID in the database or by team/date), not by score. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/226568-help-with-creating-latest-score-table/#findComment-1169400 Share on other sites More sharing options...
kenny22 Posted February 3, 2011 Author Share Posted February 3, 2011 here in uk, 3pts for win, 1 for a draw what i have come up if ($score1 > $score2) { $homepoints = '3'; $awaypoints = '0'; $homewin = 'W'; $awaywin = 'L'; } if ($score1 < $score2) { $homepoints = '0'; $awaypoints = '3'; $homewin = 'L'; $awaywin = 'W'; } if ($score1 == $score2) { $homepoints = '1'; $awaypoints = '1'; $homewin = 'D'; $awaywin = 'D'; } going to do some more work on form page so that it looks at the value of $homewin, $awaywin and allocates points from there, was hoping someone had already solved this problem before thanks for reply kenny Quote Link to comment https://forums.phpfreaks.com/topic/226568-help-with-creating-latest-score-table/#findComment-1169407 Share on other sites More sharing options...
ManiacDan Posted February 3, 2011 Share Posted February 3, 2011 Oh, so in addition to "keeping score" for the game itself, you're also "scoring" the teams in league play. Those should be kept in a separate table (or calculated on the fly). Don't give the team the 3 points until after the game is finished with. -Dan Quote Link to comment https://forums.phpfreaks.com/topic/226568-help-with-creating-latest-score-table/#findComment-1169413 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.