mardi 24 novembre 2015

Change div/button if the variable is 0 or 1 or 2 in php

my problem is this I have this variable

$tpl_dat['col']['mng_chp']

if this variable is 1 want to display a div with read now if this variable is 2 i want to display 2 div one with read now one with read now 2 and if this variable is 0 i want to display a div with not available. My actual code is this but only display the same div for all the values >=1 and antoher div is is =0:

                <div class="read-now">
                <?php if(count($tpl_dat['col']['mng_chp'])){ ?>
                    <?php foreach($tpl_dat['col']['mng_chp'] as $chp){ ?>
                        <a class="lst" href="<?php echo $chp['url']; ?>" >
                        <div class="btn-read-now">Read Now</div></a>
                        <div class="clr"></div>
                    <?php } ?>
                <?php }else{ ?>
                    <div class="btn-available">Not Available</div>
                    <div class="clr"></div>
                <?php } ?>
            </div>

The other div is:

Read Now2

Thanks.

Aucun commentaire:

Enregistrer un commentaire