Web Analytics Made Easy -
StatCounter Basic picture insert - CodingForum

Announcement

Collapse
No announcement yet.

Basic picture insert

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Basic picture insert

    Hi

    I have been searching everywhere but have not been able to find a way to just show a single picture with php code.

    eg. in HTML it is: <img src="picture.gif">

    what is it with php

    thanks for any help
    Mike

  • #2
    It's no different, just put it in print or echo eg
    PHP Code:
    <?php
    echo '<img src="picture.gif">';
    ?>
    But it is really best to escape from php when using html, makes things much easier for you

    PHP Code:
    <?php
    //php code here
    ?>
    <img src="picture.gif">
    <?php
    // more php code
    ?>

    Comment


    • #3
      What i am trying to do is
      script:

      PHP Code:
      <?php

      if ($_GET["name"] == comp)
         echo 
      "TEXT"; \\Make the picture appear with this text


         
      elseif ($_GET["name"] == lap)
         echo 
      "TEXT";
         else 
         echo 
      "wrong";
      ?>
      but i get an error when i try to
      Last edited by anarchy3200; Feb 25, 2004, 02:50 PM.
      Mike

      Comment


      • #4
        PHP Code:
        <?php

        if ($_GET["name"] == comp)
        echo 
        "TEXT";

        //Put the picture here
        echo '<img src="picture.gif">';

        elseif (
        $_GET["name"] == lap)
        echo 
        "TEXT";
        else
        echo 
        "wrong";
        ?>

        Comment


        • #5
          When i do that though i get an error:

          Parse error: parse error, unexpected T_ELSEIF in C:\apache\minixampp\htdocs\xampp\form\action.php on line 21

          which is the line with the 'elseif' statement in this.
          Mike

          Comment


          • #6
            It would be best to use curly braces in the code, like this. I changed the code to how you wanted it too.
            PHP Code:

            <?php

            if ($_GET["name"] == comp){
                echo 
            "TEXT <img src=\"picture.gif\">";
            }
            elseif (
            $_GET["name"] == lap){
                echo 
            "TEXT";
            }
            else{
                echo 
            "wrong";
            }
            ?>
            As the html for the image contains double quotes and the echo is also using dowuble quotes, you need to use backslashes in the html like I did above, or else you'll get a parse error

            Comment


            • #7
              Thanks for all your help - it is working now.
              Mike

              Comment

              Working...
              X