What I have is two values coming from a database which represent a home team's goals, and away team's goals, in a soccer game (eg 4 and 5). I want to display on the page who the winner was, so basically, I want to subtract the second value from the first one, and if the value is positive, set the result to "home". If it's even (i.e. the two values were the same), set the result to "draw", and if the value is negative, set the result to "away". Here's what I've got:
Code: Select all
$difference = $current_page['home_team_goals'] - $current_page['away_team_goals'];
if ($difference >= 1) { $result= "home"; }
elseif ($difference <= -1) { $result= "draw"; }
else { $result= "away"; }