Jump to content

Why is this ternary operator not working?


simpli

Recommended Posts

Hi,

It's my first crack at a ternary operator. It's nested in an echo and it's not working.

Can anyone troubleshoot it and tell me why? Some context: $error is an array containing possible error msg (this is in a validation form). So if the form was invalid, I want to apply the error class css that will format the field a certain way. Can you help troubleshoot? I'm stuck.

J-R

function choosePlayers($error)
{
//Choix des dix joueurs
global $nombre_joueurs;
$nbjoueurs = $nombre_joueurs;

echo '</br>';
echo '<fieldset>' . "\n";

echo '<ol>' . "\n";
for ($i=1; $i <= $nbjoueurs; $i++)
{
echo '<li><input name="player_' . $i . '" id="player_' .$i . isset($error["player_" . $i]) ? 'class="error"' :'' . '" type="text" size="30"></li></br>' . "\n";
//echo  isset($error["player_" . $i]) ? 'class="error"' :'';

}
echo '</ol>';
echo '</fieldset>';

}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.