我想在我的代码中显示一张图片,但由于某种原因,我得到了一个几乎是空白的大页面,其中包含一个损坏的链接 img。我想显示图像以及任何其他信息。我也想调整图像的大小(所以它不会覆盖整个页面)。编码:
<?php
session_start()
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0" />
<link rel="stylesheet" href="css/style.css" />
</head>
<div id="Container">
<div id="header">
<h1>Welcome!</h1>
</div>
<div id="navigation">
<?php
include_once "navigation.php";
?>
</div>
<div id="Content">
<?php
if (isset($_GET['search'])) {
$Name = $_GET['search'];
mysql_connect("localhost","root","") or die ("Could not connect to the server!");
mysql_select_db("pictures") or die ("That database could not be found!");
$query = mysql_query("SELECT * FROM picture WHERE Name='$Name'") or die ("The query could not be completed, please try again later!");
if (mysql_num_rows($wepquery) !=1) {
die ("That name could not be found!");
}
while ($row = mysql_fetch_array($query, MYSQL_ASSOC, 0)) {
$dbName = $row['Name'];
$dbCreator = $row['Creator'];
$dbDescription = $row['Description'];
$imageData = $row['Image'];
}
header("Content-type: image/jpeg");
if($Name != $dbName) {
die ("There has been a fatal error. Please try again.");
}
?>
<h2><?php echo $Name; ?></h2>
<br />
<table>
<tr><td>Creator: <?php echo $dbCreator;?></td></tr>
<tr><td>Description:<br /><?php echo $dbDescription;?></td></tr>
<tr><td>Picture:<br /><?php echo $imageData;?></td></tr>
</table>
<?php
} else die ("You need to specify a submission!");
?>
</div>
</div>
</html>
数据库:
id、名称、创建者、描述、Image_name、Image(mediumblob)。
如您所见,最后两个字段专用于图片。是的,我知道 PDO 和 MySQLi,但我只想先完成这段代码。有什么帮助吗?