0

I am trying to build a Standings page for a hockey pool site that shows Wins, Losses, Ties, etc.

I am struggling with the Tie section. If two teams have the same number of points (PF=PA) the team gets one point. I can get this part to work. However, at the very beginning of the game when it is 0-0, it still shows it as a TIE and awards 1 point for this. I want to put a condition that if both PF=0 and PA=0 that the point awarded should not be 1 but 0.

Here is what I have so far:

if ($row['PF_wk2'] == $row['PA_wk2']) {
$Tie="1";
} else {
if ($row['PF_wk2'] = "0" and $row['PA_wk2'] = "0") 
$Tie="0";
}
if ($row['PF_wk2'] != $row['PA_wk2']) {
$Tie="0";

}
echo $Tie;

Any help would be appreciated!

4
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by artech
2

Your problem is not just from the single "=" vs the "==" but logically your if else wont work. Your first if statement "if ($row == $row)" will make $tie be equal 1 when the score is 0-0 since php wont even execute the else part of your code.

The way php will read and run your code is first it will check PF-wk2 with PA_wk2 if it equals (i.e. both are 0) then it will assigned 1 to $tie and skip the rest of the if - else statement.

A simple fix is just to leave out the else clause and have three separate if statement with no else. That way php will go through sequentially and change $tie to 0 after reading and runnning the first if statement.

0

Hi,

[EDIT: sorry... didn't see this marked as solved!]

if ($row['PF_wk2'] == $row['PA_wk2']) {
     // since PF == PA, just check one of them for being zero
     if ($row['PF_wk2'] == "0") {
          // tied at zero, award zero points
          $Tie="0";
     } else {
          // tied not at zero, award 1 point
          $Tie="1";
     }
} else {
     // not a tie, award no points
     // don't really need to do a != check here since it is implied by the first condition (==)
     $Tie="0";
}

echo $Tie;

Edited by artech: thread was already marked as solved

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.