Branduo Branduo - 3 years ago 57
PHP Question

Trying to write a PHP if/else statement but failing miserably can anyone help me out?

So I'm trying to make a if/else statement in PHP, I have the if statement down and it's returning what I want, but I can't seem to figure out the else statement. Does anyone have any ideas?

<div class="row">
<?php while($items->have_posts()) : $items->the_post(); ?>

<?php

if( get_field('sauce_or_spice') ): ?>
<div class="large-4 medium-6 columns">
<h5><?php the_title(); ?></h5>
<a href="https://shop.deadeyebbq.com/password" ?>
<div class="thumbnail products">
<?php the_post_thumbnail('thumbnail'); ?>
</div>
</a>
<p><?php the_field('description'); ?></p>
<p><?php the_field('price'); ?></p>
<a class="video-button">Buy now!</a>
</div>
<?php elseif( get_field(!('sauce_or_spice')) ): ?>
<?php echo'HELLO'; ?>
<?php endif; ?>
<?php endwhile;?>
</div>

Answer Source

I think you want <?php elseif( !get_field('sauce_or_spice') ): ?>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download