2

I write this if statement inside echo statement, but it did not work correctly. Given that $row['a']=0 and $row['b']=0 from database.

.($row['a']==0 && $row['b']==0?'waiting for approval':$row['a']==1 && $row['b']==1?'Approved':'Stop running').

But it always echo Approved? It should echo 'waiting for approval' Is there something wrong with my code? Please help... many thanks

Giang Nguyen
  • 495
  • 8
  • 22
  • possible duplicate of [Using nested ternary operators](http://stackoverflow.com/questions/8735280/using-nested-ternary-operators) – user2314737 Mar 22 '15 at 05:43

1 Answers1

1

Use more parenthesis

.(($row['a'] == 0 && $row['b'] == 0) ? 'waiting for approval' : (($row['a'] == 1 && $row['b'] == 1) ? 'Approved':'Stop running')).
Jake
  • 1,469
  • 4
  • 19
  • 40