【发布时间】:2014-12-10 03:01:48
【问题描述】:
我正在尝试在网页上显示图像,其中图像路径存储在数据库中,图像存储在服务器中。但我无法使用以下代码显示这些图像,所以请有人帮我解决这个问题,..
<form method="post" enctype="multipart/form-data" action="file_upload.php">
<table>
<?php
$dbhost = 'xxxxxxxx';
$dbuser = 'xxxxxxxxx';
$dbpass = 'xxxxxxxxxx';
$db_name = 'xxxxxxxxxx';
$tbl_name = 'xxxxxxxxxxx';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("$db_name")or die("cannot select DB");
$path1 = mysql_query("select * from '$tbl_name' where id='1'");
$path2 = mysql_query("select * from '$tbl_name' where id='2'");
$path3 = mysql_query("select * from '$tbl_name' where id='3'");
echo '<tr><td><img src="$path1"></td>' ;
echo '<td><img src="$path2"></td>' ;
echo '<td><img src="$path3"></td></tr>' ;
?>
</table>
</form>
【问题讨论】:
-
您需要使用 mysql_fetch_assoc 之类的函数遍历结果集 $path1,然后选择列 $path1['image_path']
标签: php html mysql database image-processing