Where is the error that I can not see?

4

What happens in jeans_status and jeans_opcao it works a beauty more in the first if does not work, it enters if without checking whether imagem_status == 1 and imagem_opcao == 'galeria_imagem' . Can anyone explain to me what you're getting at?

<?php
            //  pd($imagens);
            foreach ($imagens as $value) {
                if (isset($value->imagem_status) == 1 and $value->imagem_opcao == "galeria_imagem") {
                    ?>
                    <div class="portfolio-item col-md-3 code">

                        <figure>
                            <a class="example-image-link" href="<?php echo base_url('tema/assets/img/site/' . $value->imagem_link); ?>" data-lightbox="example-set" data-title="<?php echo $value->imagem_descricao ?>">
                                <div class="image-hover">
                                    <img width="200px" height="200px" src="<?php echo base_url('tema/assets/img/site/' . $value->imagem_link); ?>" alt="<?php echo $value->imagem_titulo ?>">
                                    <h5 class="margin-top-20"><?php echo $value->imagem_titulo ?></h5>
                                </div>
                            </a>
                            <div class="overlay">

                            </div>
                        </figure>




                        <div class="clearfix"></div>
                    </div>

                <?php } elseif ($value->jeans_status == 1 and $value->jeans_opcao == "galeria_jeans") { ?>
                    <div class="portfolio-item col-md-3 code">



                        <figure>
                            <a class="example-image-link" href="<?php echo base_url('tema/assets/img/jeans/' . $value->jeans_link); ?>" data-lightbox="example-set" data-title="<?php echo $value->jeans_descricao ?>">
                                <div class="image-hover">
                                    <img width="200px" height="200px" src="<?php echo base_url('tema/assets/img/jeans/' . $value->jeans_link); ?>" alt="<?php echo $value->jeans_titulo ?>">
                                    <h5 class="margin-top-20"><?php echo $value->jeans_titulo ?></h5>
                                </div>
                            </a>
                            <div class="overlay">
                            </div>
                        </figure>




                        <div class="clearfix"></div>

                    </div>
                    <?php
                }
            }
            ?>
    
asked by anonymous 10.10.2016 / 16:38

1 answer

4

The current check compares if the result isset() is true and if imagem_opcao is galeria_imagem . I also suggest that you change and to && since they are not equal, have different priorities.

Change:

isset($value->imagem_status) == 1 and $value->imagem_opcao == "galeria_imagem"

To:

isset($value->imagem_status) && $value->imagem_status == 1 && $value->imagem_opcao == "galeria_imagem"

Recommended reading:

What's the difference between "& &" and "||" and "and" and "or" in PHP ? Which one to use?

    
10.10.2016 / 16:47