这是我的代码 -
<?php
$con = mysql_connect('db', 'table', 'p/w');
if (!$con) {
die('Could not connect: ' . mysql_error()); }
mysql_select_db("db", $con);
$result = mysql_query("SELECT * FROM computers WHERE KEYWORDS='Computers,Desktops'");
echo "<table border='1' width='100%' >";
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['NAME'] . "</td>";
echo "<td>" . $row['MANUFACTURER'] . "</td>";
我想在其中一列
中显示来自db存储为路径的图像echo "</tr>"; }
echo "</table>";
mysql_close($con);
?>
任何人都可以帮忙吗?感谢
答案 0 :(得分:2)
<?php
$con = mysql_connect('db', 'table', 'p/w');
if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("db", $con);
$result = mysql_query("SELECT * FROM computers WHERE KEYWORDS='Computers,Desktops'");
echo "<table border='1' width='100%' >";
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['NAME'] . "</td>";
echo "<td>" . $row['MANUFACTURER'] . "</td>";
echo "<td><img src='folder_name/".$row['image_name']."'></td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
folder_name =保存图像的文件夹的名称
image_name =表名计算机中图片的字段名称
答案 1 :(得分:0)
您可以在任何地方使用img元素来显示图像。
echo "<img src='" . $row['image'] . "'>"
。您还可以查看img element for HTML或img element for HTML5