how do i display an image in php?

Discussion in 'PHP' started by whiteblue1942, Mar 8, 2008.

  1. #1
    trying to do somthign liek this:

    <?php
    $card1=rand(2, 4);

    if ($card1==2)
    echo "you got a 2";
    display a picture of the 2 of hearts
    elseif ($card1==3)
    echo "you got a 3";
    display a picture of the 3 of hearts
    else ($card1==4)
    echo "you got a 4";
    display a picture of the 4 of hearts
    ?>
     
    whiteblue1942, Mar 8, 2008 IP
  2. quicksolutions

    quicksolutions Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this one,change the images path accordingly

    <?php
    $card1=rand(2, 4);
    $img2="./heartimages/heart2.jpg";
    $img3="./heartimages/heart3.jpg";
    $img4="./heartimages/heart4.jpg";

    if ( $card1==2 )
    { echo "you got a 2";
    echo "<img src=$img2 border='0' >";
    }
    elseif ($card1==3)
    {
    echo "you got a 3";
    echo "<img src=$img3 border='0' >";
    }
    else
    {
    echo "you got a 4";
    echo "<img src=$img4 border='0' >";
    }
    ?>
     
    quicksolutions, Mar 8, 2008 IP
  3. whiteblue1942

    whiteblue1942 Peon

    Messages:
    573
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks! rep added!
     
    whiteblue1942, Mar 8, 2008 IP