Just trying to write an if statement for this situation: We do have some attributes which could have 3 values: empty space, yes and no.

The statement should require a yes value to display a jpg and if the no or empty is set display nothing or unset the jpg.

Now i am not sure about the syntax of that statement. What works so far is to display the jpg if the value exists in the first place.

So this is the syntax yet:

<?php $jpg= '<img src="jpg">'; ?>

if ($_product->getAn_55() != 0 && $_product->getAn_55() != ""):; ?>

<div class="new" style="border:0px solid #e2e2e2; float:right; padding-top:3px; padding-left:5px">
<?php echo ($jpg);?>

<?php endif?>

Now i was trying within the above sytanx like

elseif ($_product->getAn_55() == false ):; ?>
<?php unset ($jpg)

elseif ($_product->getAn_55() == no ):; ?>
<?php unset ($jpg)

Which both doesn't work. So, whats the correct syntax for checking if a attribute has value set to yes or no?

I generally wonder, what value has to be set in the statement for text value or number value or MySQL Option Value and where to find it.

Would be nice, if anyone could give me some quick hint on this

  • What is you attribute code?
    – Mujahidh
    Commented Apr 21, 2016 at 8:38

1 Answer 1


you need to compare the strings using strcmp() like


then do your logic. or try by giving ' ' to no and yes in your code.

  • unfortunately doesn´t work both. Do you maybe know where the options "no" value ID is stored in the MySQL Database?
    – user37184
    Commented Apr 21, 2016 at 12:33
  • i don't know that, but i think if the attribute is yes/no type then it is stored by 1 or 0 in the database and you should check it by printing the value of $_product->getAn_55()
    – Shrikant
    Commented Apr 21, 2016 at 13:08
  • stackoverflow.com/questions/9463580/… maybe this helps you
    – Shrikant
    Commented Apr 21, 2016 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.