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条)

报告相同问题?

悬赏问题

  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 经gamit解算的cors站数据再经globk网平差得到的坐标做形变分析
  • ¥15 GD32 SPI通信时我从机原样返回收到的数据怎么弄?
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题
  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题