jeudi 18 août 2016

PHP - if statment inside echo with checkbox

I need some help to resolve my issue. I did several investigations without any success. I have a table with a IsContrib column which is BOOLEAN. I want to display this column with my checkbox. If IsContrib=1 ==> checked else IsContrib=0 unchecked.

Here, how I did, but I get an error saying: syntax error, unexpected ';'

I trid to do like so:

echo "...
<td>&nbsp;<input name='checkboxNContrib[]' type='checkbox' id='checkboxNContrib[]' ".$rowNContribRunDis["IsNContrib"]==TRUE ? "checked='checked'"." value='".$rowNContribRunDis["IdVariantNContrib"]."'/>&nbsp;</td></tr>";

Here the whole echo:

    while($rowNContribRunDis = mysqli_fetch_assoc($PerformNContribSELECT)){
    $id = $rowNContribRunDis["IdVariantNContrib"];

    echo "<tr>
<td>&nbsp;".$rowNContribRunDis["ID"]."&nbsp;</td><td>&nbsp;".$rowNContribRunDis["Reference"]."&nbsp;</td>
<td><textarea name='ResultHRM[$id]' id='ResultHRM[]' cols='30' rows='1'>".$rowNContribRunDis['ResultHRM']."</textarea></td>
<td><textarea name='Commentaires[$id]' id='Commentaires[]' cols='60' rows='1'>".$rowNContribRunDis['Commentaires']."</textarea></td>
<td>&nbsp;<input name='checkboxNContrib[]' type='checkbox' id='checkboxNContrib[]' ".$rowNContribRunDis["IsNContrib"]==TRUE ? "checked='checked'"." value='".$rowNContribRunDis["IdVariantNContrib"]."'/>&nbsp;</td></tr>";

Aucun commentaire:

Enregistrer un commentaire