Jump to content

Recommended Posts

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'"; 
            }

 

Link to comment
https://forums.phpfreaks.com/topic/52822-if-else-help-please/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/52822-if-else-help-please/#findComment-260782
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.