如何在中显示blob图像

时间:2017-03-06 11:30:21

标签: php

这是我的数据库连接代码。

 

我想将blob图像显示为td

<?php while ($news = mysql_fetch_assoc($content))
            {
                echo "<tr>";
                    echo "<td>" .$news['<img src = "data:image/jpg;base64,'.base64_encode($img).'"/>'].  "</td>";
                echo "</td>";

                echo "<tr>";
                    echo "<td>" .$news['title']."</td>";
                echo "</td>";

                echo "<tr>";
                    echo "<td>" .$news['content']."</td>";
                echo "</td>";

                echo "<tr>";
                    echo "<td>" .$news['date']."</td>";
                echo "</td>";

                echo "<tr>";
                    echo "<td>" .$news['author']."</td>";
                echo "</td>";
            }

            ?>

我得到一个错误说未定义索引

1 个答案:

答案 0 :(得分:0)

您的代码中有拼写错误。改变你的行:

echo "<td><img src='data:image/jpg;base64,".base64_encode($news['img'])."'/></td>";

通过

{{1}}