图像不能用PHP显示

图像不能用PHP显示,php,mysql,Php,Mysql,我有这个php代码() 还有php代码() 和MySQL CREATE TABLE IF NOT EXISTS `menu` ( `no` int(100) NOT NULL AUTO_INCREMENT, `ref` varchar(30) NOT NULL, `course` text NOT NULL, `name` text NOT NULL, `price` int(10) NOT NULL, `description` text NOT NULL, `pi

我有这个php代码()

还有php代码()

和MySQL

CREATE TABLE IF NOT EXISTS `menu` (
  `no` int(100) NOT NULL AUTO_INCREMENT,
  `ref` varchar(30) NOT NULL,
  `course` text NOT NULL,
  `name` text NOT NULL,
  `price` int(10) NOT NULL,
  `description` text NOT NULL,
  `picture` longblob NOT NULL,
  PRIMARY KEY (`no`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
图像显示中的问题。为什么无法显示图像?

请尝试以下代码:

 echo"<tr>";   
                    echo"<td>" .$test['ref']."</td>";
                    echo"<td>" .$test['course']."</td>";
                    echo"<td>" .$test['name']."</td>";
                    echo"<td>Rp.".$test['price']."</td>";
                    echo"<td>" .$test['description']."</td>"; ?>
                    <td><img src='http://mysite.com/image/<?php echo $test['picture']; ?>' height="100" width="100" /> <?php echo "</td>";
                    echo"<td> <a href ='edit.php?ref=$id'><center>Edit</a></td>"; 
                    echo"<td> <a href ='del.php?ref=$id'><center>Delete</a></td>";
                    echo"<td></td>";
                    echo "</tr>"; 
echo”“;
echo“$test['ref']”;
echo“$test['course']”;
echo“$test['name']”;
回音“Rp.”$test[“价格]”;
echo“$test['description']”;?>
'height=“100”width=“100”/>相关代码如下:

echo"<td>";?><img src='image/".$test['picture']."' height="100" width="100" /> <?php echo "</td>"; 

echo”“;?> 为什么使用php标记关闭?>当您需要每个tr的图像时,您需要这样做:

while($test = mysql_fetch_array($result))
            {

                $id = $test['ref']; 


                echo"<tr>";   
                echo"<td>" .$test['ref']."</td>";
                echo"<td>" .$test['course']."</td>";
                echo"<td>" .$test['name']."</td>";
                echo"<td>Rp.".$test['price']."</td>";
                echo"<td>" .$test['description']."</td>"; 
                echo"<td><img src='image/".$test['picture']."' height='100' width='100' />";
                echo "</td>";
                echo"<td> <a href ='edit.php?ref=$id'><center>Edit</a></td>"; 
                echo"<td> <a href ='del.php?ref=$id'><center>Delete</a></td>";
                echo"<td></td>";
                echo "</tr>";
            } 
while($test=mysql\u fetch\u数组($result))
{
$id=$test['ref'];
回声“;
echo“$test['ref']”;
echo“$test['course']”;
echo“$test['name']”;
回音“Rp.”$test[“价格]”;
echo“$test['description']”;
回声“;
回声“;
回声“;
回声“;
回声“;
回声“;
} 

图片列是BLOB。这意味着您不能直接在标记中显示它。您需要有一个php脚本来显示图像,并在src属性中链接到该脚本

img.php
$no = $_GET['no'];

// fetch the record from the database into $image (be careful at sql injection)

// Check the mime type of the image and add the appropriate header
//header('Content-Type: image/gif');
//header('Content-Type: image/png');
header('Content-Type: image/jpeg');

echo $image['picture'];
然后像这样显示图像:

$no = $_GET['no'];

// fetch the record from the database into $image (be careful at sql injection)

// Check the mime type of the image and add the appropriate header
//header('Content-Type: image/gif');
//header('Content-Type: image/png');
header('Content-Type: image/jpeg');

echo $image['picture'];
<img src="img.php?no=<?php echo $dbRecord['no']; ?>" />
“/>

代码不完整,但您应该了解它。

您应该在问题中包含相关代码(而不是所有内容的链接)。这会让人们更容易理解你想做什么!我刚检查了你提供的链接,然后为什么要否决投票?你能举一个例子,说明你的一张图片的来源是什么吗?@Paddy阅读问题,看看链接是什么,如果你看到他遗漏了什么,现在应该显示图片。不要t将图像存储在数据库中。存储到图像的链接。如果使用php提供图像,则应创建一个类似image.php的文件,然后在显示图像时执行image.php?id=