如何在img src标签中调用php?

How to call php in img src tag?

这是我的代码片段 index.php:

<div class="row">
<?php 
    $conn = mysql_connect("localhost","root","");
    mysql_select_db("imdb_db");
    $res = mysql_query("select * from `film` ORDER BY ID DESC");
    while($row = mysql_fetch_array($res)) {
        ?><div class='col-xs-2'><?php
        ?><p style="position:relative;left:-40px"><?php echo $row["Cim"];?></p><?php
        ?> <img src="php/imageView.php?ID=<?php echo $row["ID"];?>" class="img-responsive" style="width:200px;height:250px;" alt="Image"> <?php 
        ?></div><?php
    }
    mysql_close($conn);
?>
</div>

这是imageView.php:

<?php
    $conn = mysql_connect("localhost","root","");
    mysql_select_db("imdb_db") or die(mysql_error());
    if(isset($_GET['ID'])) {
        $sql = "SELECT `Boritokep` FROM `film` WHERE ID=". $_GET['ID'];
        $result = mysql_query("$sql") or die("<b>Error:</b> Problem on Retrieving Image BLOB<br/>" . mysql_error());
        $row = mysql_fetch_array($result);
        echo $row["Boritokep"];
    }

    mysql_close($conn);
?>

这是结果:

使用 php/imageView.php?ID=<?php echo $row["ID"] 我得到我的文件的路径:

uploads/film/pic/5.jpg

为什么不显示图像?

Why it doesn't displays the image?

因为 php/imageView.php?ID=<?php echo $row["ID"];?> return 是图像的路径而不是 return 图像本身。

imageView.php 可以采用该路径并将用户代理重定向到它:

header(sprintf('Location: %s', $row["Boritokep"]));