标记ifs的问题

Hello stackoverflow people, i need some information about what im doing. Is it possible to make 2 ifs in one tag? for example if(a > b) then a=a; else if (c>d) then a=c; else a=d; I'm trying to do something like this. Here it is the code:

echo '<select class="text" name="task_type">';
foreach ($task_types as $key => $value) {
    echo '<option value="'.$key.'"'.($key == $obj->task_type ? 'selected="selected"' : $key == '-1' ? 'selected="selected"' : '').'>'.$value.'</option>';
}
echo '</select>';

In the option tag you can see these ifs. But problem is that, when it eching. It selects -1 key, and the $obj->task_type key. But it should only pick this $obj->task_type.

There is a problem with placing of brackets. The correct syntax is -

(expr1) ? (expr2) : (expr3)

 echo '<select class="text" name="task_type">';
 foreach ($task_types as $key => $value) {
    echo '<option value="'.$key.'"'.($key == $obj->task_type )?      'selected="selected"' : ($key == '-1') ? 'selected="selected"' : '' .'>'.$value.'</option>';
}
echo '</select>';