dongxuan2015 2013-07-30 06:51
浏览 38
已采纳

使用echo [duplicate]在我的页面中显示图像

This question already has an answer here:

this is code of the page that I will get the image from(work perfectly)

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

    $id = $_GET['id'];
    $query = mysql_query("SELECT * FROM news WHERE id=$id");
    $row = mysql_fetch_assoc($query);

    header("Content-type: image/jpeg");
    echo $row['image'];
?>

and this is my page that i get the image to in

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

    $id = $_GET['id'];

    function showNews() {
        $data = array( 'id' => $id );
        $base = "includes/getImage.php";
        $url = $base. "?" . "id=36";
        echo $url;
        echo '<img src=includes/getImage.php class="newsImage">';
        echo '<h1><p class="subjecTitle">هنا العنوان</p></h1>   
                 <div class="newsContent">
                    hihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihihi
             </div>
        ';
    }
?>

<!DOCTYPE html>
<html>
    <head>
        <title>عينٌ على الحقيقة</title>

        <meta charset="utf-8">

        <link rel="stylesheet" type="text/css" href="css/mainstyle.css">
        <link rel="stylesheet" type="text/css" href="css/showstyle.css">
        <script lang="javascript">
            function logout( myFrame ) {
                myFram.submit();
            }
        </script>
    </head>
    <body>
        <div class="wrapper">
            <?php headerCode(); ?>
            <div class="content" dir="rtl">
                <?php showNews(); ?>
            </div>
        </div>
    </body>
</html> 

i think my wrong is in , can someone tell me how can I solve it?, sorry for my bad english

</div>
  • 写回答

3条回答 默认 最新

  • dongniechi7825 2013-07-30 07:13
    关注

    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>
                ';
            }
        ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?