Jump to content

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>';

}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.