我无法从我的数据库中检索图像

Shu*_*hum 5 php sql database image

我有一个包含电影名称,他们的描述和封面图片的数据库.封面图片字段类型为blob,问题是我无法从数据库中检索它.我想在旁边的封面图片上显示电影名称......怎么做..这是我的代码..

<?php

include ("php/connection.php");
$ID = $_GET['id'];
$listmovies = "SELECT * FROM movies where Genres LIKE '%$ID%'";
$result = mysql_query($listmovies);
while ( $row = mysql_fetch_assoc($result) ) {
    ?>
<table border="1" width="100%">
    <tr>
        <td rowspan="2" width="90" height="120">
<?php

    // set the header for the image
    header("Content-type: image/jpeg");
    echo $row['Image'];

    ?> </td>
        <td width="200" height="10">
<?php

    echo $row['Title'];
    ?></td>
    </tr>
    <tr>
        <td width="200" height="110"><a
            href="php/moredetails.php?id=<?php echo $row['ID']; ?>">More Detail</a></td>
    </tr>
<?php } ?> </table>
Run Code Online (Sandbox Code Playgroud)

我只是想在影片的标题旁边展示Imgaes?

Mol*_*iel 0

我建议这样的事情:

创建一个新的 php 文件,例如 image.php;该文件将替换物理图像文件。在该文件中,您放置帖子中的代码以及一些从数据库获取图像数据的逻辑;

在父模板(可能是 php 文件)中,您放置图像代码:

<img src="image.php?id_movie=<?php echo $id_movie; ?>" width ="200" height="200" /> More Detail
Run Code Online (Sandbox Code Playgroud)

在 image.php 中,我建议小心 php 标签之外的空格(在开头和末尾)。另外,对于 image.php,您需要提供电影的 id 才能知道要从数据库加载什么图像。