Mr Chris Posted May 24, 2007 Share Posted May 24, 2007 Hi All, Wondering if someone could help me with a league table system I’m creating. Basically I have two teams I enter in a textbox and the goals the two teams have scored. Now here are my rules: They all work apart from an away team win, and I can’t figure out why? Anything obvious here? Thanks Chris // Set Rules for a home team win - this works if($team_1_score > $team_2_score) { $result = " update league_table set league ='p', team_wins=team_wins+1, team_gf=team_gf+'$team_1_score', team_ga=team_ga+'$team_2_score', team_points_total=team_points_total+3 where team_name='$team_1'"; $result_2 = "update league_table set league ='p', team_losses=team_losses+1, team_gf=team_gf+'$team_2_score', team_ga=team_ga+'$team_1_score' where team_name='$team_2'"; // Set Rules for an away team win - does not work – Query was empty? } else if($team_1_score < $team_2_score) { //Note: also tried //} else if($team_2_score > $team_1_score) { $result = " update league_table set league ='p', team_losses=team_losses+1, team_gf=team_gf+'$team_1_score', team_ga=team_ga+'$team_2_score' where team_name='$team_1'"; $result2 = "update league_table set league ='p', team_wins=team_wins+1, team_gf=team_gf+'$team_2_score', team_ga=team_ga+'$team_1_score', team_points_total=team_points_total+3 where team_name='$team_2'"; // Set Rules for a draw – this works } else if($team_1_score == $team_2_score) { $result = " update league_table set league ='p', team_draws=team_draws+1, team_gf=team_gf+'$team_1_score', team_ga=team_ga+'$team_2_score', team_points_total=team_points_total+1 where team_name='$team_1'"; $result_2 = " update league_table set league ='p', team_draws=team_draws+1, team_gf=team_gf+'$team_2_score', team_ga=team_ga+'$team_1_score', team_points_total=team_points_total+1 where team_name='$team_2'"; } Quote Link to comment https://forums.phpfreaks.com/topic/52822-if-else-help-please/ Share on other sites More sharing options...
trq Posted May 24, 2007 Share Posted May 24, 2007 They all work apart from an away team win, and I can’t figure out why? And we can't figure out what [doesn't work[/i] means. You might want to descibe your actual problem. Post the related output of any debugging you have attempted. Quote Link to comment https://forums.phpfreaks.com/topic/52822-if-else-help-please/#findComment-260777 Share on other sites More sharing options...
Mr Chris Posted May 24, 2007 Author Share Posted May 24, 2007 Thanks, but I b believe I did above! // Set Rules for an away team win - does not work – Query was empty? But let me make myself a bit clearer. In a football match you can: - Win a home game - Win an away game - Draw a game Now in my code above i've got a rule for a home win, a draw, and the away win. Now each of these populates data in the database apart from the away win rule, so I just wanted someone to cast their eye over it quickly to see if there was anything glaringly obvious I missed as to why ths rule is not populating. Thanks Chris Quote Link to comment https://forums.phpfreaks.com/topic/52822-if-else-help-please/#findComment-260782 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.