MySql,PHP在HTml上显示图片 [英] MySql, PHP display Picture on HTml
本文介绍了MySql,PHP在HTml上显示图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用Php显示保存在数据库中的图片,但是我得到的是Url链接,它保存在数据库中,而不是图片,我认为这个语法是错误的。
<?php
echo< table border = \1 \align = \center \ > 中;
echo< tr>
< th>名称>
< th>描述< / th>
< th> Price< / th>
< th>制造商< />
< th>图像< / th>
< / tr>
while($ row = mysql_fetch_array($ result))
{
echo< tr>;
回显< td> 。$行[名称] < / TD> 中。
回显< td> 。$ row ['Description']。< / td>;
回显< td> 。$ row ['Price']。< / td>;
回显< td> 。$ row ['Manufacturer']。< / td>;
回显< td> 。$ row ['ImageURL']。< / td>;
回声< / tr>;
}
echo< / table>;
?>
< / p>
<?php
解决方案
构建一个< img>
元素,而不仅仅是输出图片的URL。 尝试替换:
im trying to display the picture saved in the database using Php, but what i get is Url link which was saved in the database and not the picture, i think the syntax is wrong.
<?php
echo "<table border=\"1\" align=\"center\">";
echo "<tr>
<th>Name</th>
<th>Description</th>
<th>Price</th>
<th>Manufacturer</th>
<th>Image</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" .$row['Name']."</td>";
echo "<td>" .$row['Description'] ."</td>";
echo "<td>" .$row['Price'] ."</td>";
echo "<td>" .$row['Manufacturer'] ."</td>";
echo "<td>" .$row['ImageURL'] ."</td>";
echo "</tr>";
}
echo "</table>";
?>
</p>
<?php
解决方案
You need to construct an <img>
element, not just output the image URL.
Try replacing this: $row['ImageURL']
With this: "<img src='".$row['ImageURL']."' />
这篇关于MySql,PHP在HTml上显示图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文