当前位置: 动力学知识库 > 问答 > 编程问答 >

php - display image in my page using echo

问题描述:

This question already has an answer here:

  • upload image to mysql database php

    1 answer

网友答案:

Cleared it up for you:

echo '<img src="includes/getImage.php?id=' . $id . '" class="newsImage">';

Should 100% work (if the $id param has a value of course).

Update to fix the missing $id var:

    <?php
        ob_start();
        session_start();
        include('includes/connect.php');
        include('includes/phpCodes.php');

        $id = $_GET['id'];

        function showNews(){
            $id = $_GET['id'];
            $base = "includes/getImage.php";
            $url = $base. "?" . "id=36";
            echo $url;
            echo '<img src="includes/getImage.php?id=' . $id . '" class="newsImage">';

            echo '
                <h1><p class="subjecTitle">??? ???????</p></h1> 
                <div class="newsContent"></div>
            ';
        }
    ?>
网友答案:

why are you using two different pages? put both code in single page and simply do this

 <img src=includes/<?php echo $row['image']; ?> class="newsImage">
网友答案:

Change :

echo ' <img src=includes/getImage.php class="newsImage">';

To :

echo ' <img src="includes/getImage.php?id='.$id.'" class="newsImage">';

Please note src has " and also make sure that includes/getImage.php return a image path

分享给朋友:
您可能感兴趣的文章:
随机阅读: