If database field = Y display image

Discussion in 'PHP' started by dhblewis, Mar 6, 2010.

  1. #1
    Hey,

    I am created a php page where I print info from a database using

    <td><?=$mf['receivep']?></td>

    I would like it that if receivep = y it will show a tick if it = n it will display a image of a x.

    How do I do that.

    Rgds
    Daniel
     
    dhblewis, Mar 6, 2010 IP
  2. fibi

    fibi Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <td><?
    if ($mf['receivep'] == "n")
    {
       echo '<img src="image_x.png">';
    } else {
       echo '<img src="image_y.png">';
    }
    ?></td>
    
    PHP:
    In this case the it will show the image_x.png if it is "n" otherwise it will show the image_y.png
     
    fibi, Mar 6, 2010 IP
  3. sunlcik

    sunlcik Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey guy,Try this:
    <td>
    <?php
    if($mf['receivep'] == 'y')
    {
    ?>
    <img src="The image url what you want to show.">
    <?php }else{ ?>
    <img src="The image url what you want to show.">
    <?php } ?>
    </td>
     
    sunlcik, Mar 6, 2010 IP
  4. dhblewis

    dhblewis Guest

    Messages:
    466
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks works like a charm!
     
    dhblewis, Mar 6, 2010 IP