我已经使用 phpmyadmim 创建了一个数据库并访问它,我创建了一个 name.php 文件。
访问注册号,名称很容易,但图像检索并非如此。我使用 LongBlob 作为类型通过 phpmyadmin 存储了图像..但我无法显示它..
如何检索图像?
如果有人可以提供帮助,我们将不胜感激。
谢谢,LJ
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PHYTOCHEMICAL DB</title>
<style type="text/css">
body {
font-family: Georgia, "Times New Roman",
Times, serif;
color: purple;
background-color: #EEEEEE}
</style>
</head>
<body>
<table width="800" border="" align="center">
<tr>
<td colspan="2" style="background-color:#FFA500;height:30px;width:700px">
<div> <img src="leaves.jpg" height="300" width="900"/> </div> <br/>
</td>
</tr>
<tr>
<td style="background-color:#FFD700;width:250px;">
<b>Menu</b><br>
<i> <a href="home.php">Home</a><br>
<i> <a href="did.php">Search by Database ID (DID)</a> <br>
<i><a href="mw.php">Search by Molecular weight<br>
</td>
<td style="background color:#EEEEEE;height:500px;width:800px;">
<form action="" method="POST">
<p> Enter the name </p>
<input type="text" name="pname">
<input type="submit" value="submit" name="submit1">
<br>
</form>
<?php
$mysqli = new mysqli("localhost", "root", "osddosdd", "phychem");
if (mysqli_connect_errno()) {
printf("Connect failed:%s\n", mysqli_connect_error());
exit();
}
if (isset($_POST['submit1'])) {
$pname = $_POST['pname'];
$query = ("select * from pchem where name LIKE '$pname'");
$result = $mysqli->query($query);
echo 'The retrieved query is:';
echo "<table border='1'>
<tr>
<th>DID</th>
<th>Name</th>
<th>Molecular weight</th>
</tr>";
while ($row = $result->fetch_row()) {
echo '<tr>';
printf("<th>%d</th> <th> %s </th> <th> %2f </th>", $row[0], $row[1], $row[2]);
echo '</tr>';
echo '</table>';
}
}
$mysqli->close();
?>
</td>
</table>
</body>
</html>