mercredi 13 juillet 2016

IF statement show image when number is higher then 0

I have this few line of codes to show a 'badge'

if a user has earned one batch I manualy put the number in the database colom idea_badge at the user profile table.

So in my view i have this line of code to show the amount of badges:

<a style="font-weight:bold; font-family: Roboto-Black!important; ">
IDEA BADGES:&nbsp;</a>
<?= $user_info['idea_badge']?>

This works just fine.

Now I want to echo the badge image. I thought I can make it like this, if the number in the database is higher then 0 echo the src ....

So for that I made this line of code:

<?php
    $idea_badge = ['idea_badge'];
    if ($idea_badge > 0) {
       print '<img style="width: 30px; height:30px;" src="http://ift.tt/29WuWzB" border=0>'; 
    }

?>

I don't get any errors on my view. But it seems like it only prints the image and don't anything do with the IF statement.

Can you help me make this statement working?

Aucun commentaire:

Enregistrer un commentaire