Hi tictike,
this code is fine. You just have to print the $action variable and pass mode=edit or delete in the querystring. It is showing the right thing to me.
It’s very important where you place parenthesis in nested ternary operators. Basically if you want a nest a ternary operator in an existing ternary operator you need to put parentheses around the whole thing your nesting.