我从路径存储在MySQL数据库中的图像创建缩略图。但是,当我回显缩略图时,仅显示图像图标,而不显示缩略图。我需要改变什么?请保持您的答案简单,因为我是PHP新手。如何回显在php中动态生成的缩略图?
这里是我使用的代码:我试图用许多其他功能
<?php
//database connectivity code
$query = mysql_query("SELECT * FROM images");
while($row = mysql_fetch_array($query))
{
$im = imagecreatefromjpeg($row['image_path']);
$width = imagesx($im);
$height = imagesy($im);
$imgw = 150;
$imgh = $height/$width * $imgw;
$thumb = imagecreatetruecolor($imgw,$imgh);
imagecopyresampled($thumb,$im, 0,0,0,0,$imgw, $imgh, ImageSX($im), ImageSY($im));
?>
<img src = "<?php echo $thumb ?>" >
<?php
} //closing while
?>
但没有做太大的帮助。他们中的大多数人显示了一串不可读的数据。请指出该怎么做。
在此先感谢。
谢谢回复。我试了一下,但它似乎也没有这样工作。它仍然只显示图像图标来代替缩略图。 – Leeds
你能从你的代码中获得更多吗?这种方法应该可以工作,但这取决于你的环境 –
嗯,我想通了。我必须用中的php标签替换您建议的 Leeds