Nicolas Boulein
Nicolas Boulein

Reputation: 15

Ternary Logic php issue

The var $bt_ent contain the letter 'V' or 'L', so why the visibility of my td stay empty? My Ternary Logic isn't good ?

My code :

<?php $bt_ent = $this->depotInformation->bt_entite->getValue() ?>
<td style="visibility : <?php $bt_ent = 'V' ? 'visible' : 'hidden'; ?>">
    <div id="poidUnitaire" style="margin:0px 100px 0px 0px;" >

The DevTools :

<td style="visibility : ">
    <div id="poidUnitaire" style="margin:0px 100px 0px 0px;">

Thanks

Upvotes: 0

Views: 50

Answers (2)

Nathan Kolpa
Nathan Kolpa

Reputation: 89

you are assigning $bt_ent instead of printing it.

change

<?php $bt_ent = 'V' ? 'visible' : 'hidden'; ?>

to

<?php echo ($bt_ent == 'V' ? 'visible' : 'hidden'); ?>

Upvotes: 0

Hecke29
Hecke29

Reputation: 754

You are assigning ( = ) instead of comparing ( == ). Also an echo is missing to actually output the result.

<?php $bt_ent = $this->depotInformation->bt_entite->getValue() ?>
<td style="visibility : <?php echo $bt_ent == 'V' ? 'visible' : 'hidden'; ?>">
    <div id="poidUnitaire" style="margin:0px 100px 0px 0px;" >

Upvotes: 2

Related Questions