如何在php表单产品表中显示mysql blob图像
经过两天的搜寻,我来到这里,希望能找到解决办法。 我试图用BLOB类型显示上传到数据库中的图像,但出现了一些问题,图像没有显示图像的64代码 代码如下:如何在php表单产品表中显示mysql blob图像,php,mysql,image,blob,Php,Mysql,Image,Blob,经过两天的搜寻,我来到这里,希望能找到解决办法。 我试图用BLOB类型显示上传到数据库中的图像,但出现了一些问题,图像没有显示图像的64代码 代码如下: <div id="container"> <img src ="banner.jpg" width="400" height="100"/> <div id="menu"> <h3> <li><a
<div id="container">
<img src ="banner.jpg" width="400" height="100"/>
<div id="menu">
<h3>
<li><a href="refresher.php">Home </a> </li>
<li><a href="refresher2.html">About </a> </li>
<li><a href="refresher3.html">Category </a>
<ul> <li><a href="Boys.php">Boys</a></li>
<li><a href="Girls.php">Girls</a></li>
<li><a href="#">Uni</a></li>
</ul>
</li>
<li><a href="refresher3.html">Costume Hire </a> </li>
<li><a href="refresher3.html">Contact</a> </li>
</h3>
<!-- <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> -->
<!-- HTML for SEARCH BAR -->
<div>
<form id="tfnewsearch" method="get" action="http://www.google.com">
<input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton">
</form>
<div class="tfclear"></div>
</div>
</div>
<div id="content">
<?php
//connect to the server and create database.
$host = "";
$userMS = "";
$passwordMS = "";
$connection = mysql_connect($host,$userMS,$passwordMS) or die("Couldn't connect:".mysql_error());
$database = "projectDataBase";
$db = mysql_select_db($database,$connection) or die("Couldn't select database");
//build the table to show the records.
echo("<table>");
echo("<tr>
<th>Product ID</th>
<th>Product Name</th>
<th>Product Image</th>
<th>Age</th>
<th>Stauts</th>
<th>Price</th>
</tr>");
//database query to show all the records.
$selectString = "SELECT
Product.Product_ID,
Product.Product_Name,
Product.Image,
Gender.Gender_Description,
Category.Description,
`Status`.Availability,
Product.Price,
Age.Age_Description
FROM
Product
JOIN
Age ON Product.Age_ID = Age.Age_ID
JOIN
Category ON Product.Category_ID = Category.Category_ID
JOIN
Gender ON Product.Gender_ID = Gender.Gender_ID
JOIN
`Status` ON Product.Status_ID = `Status`.Status_ID
";
$result = mysql_query($selectString);
while ($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the Product image.
if($index == "Image")
{
echo("<td><img src = $value alt = 'Image'></td>");
}
else{
echo("<td>$value</td>");
}
$self = htmlentities($_SERVER['PHP_SELF']);
echo("<form action = '$self' method='POST'>");
echo "<input type='hidden' name='athID' value='$row[Product_ID]' >";
/*echo("<td><input type='submit' name='delete' value = 'Delete'/></td>");*/
echo ("</form>");
echo("</tr>");
echo("</tr>");
}
echo("</table>");
/*
echo("<table>");
echo("<tr>
<th>Country Code</th>
<th>Country Name</th>
<th>Population</th>
<th>Image</th>
</tr>");
$selectString = "SELECT * from tblCountries";
$result = mysql_query($selectString);
while($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the country image.
if($index == "flag_image")
{
echo("<td><img src = $value alt = 'countryImage'></td>");
}
else{
echo("<td>$value</td>");
}
echo("</tr>");
}
echo("</table>");
*/
mysql_free_result($result);
?>
</div>
<footer>Copyright © Hucos Pucos Shop</footer>
</div>
<div id="container">
<img src ="banner.jpg" width="400" height="100"/>
<div id="menu">
<h3>
<li><a href="refresher.php">Home </a> </li>
<li><a href="refresher2.html">About </a> </li>
<li><a href="refresher3.html">Category </a>
<ul> <li><a href="Boys.php">Boys</a></li>
<li><a href="Girls.php">Girls</a></li>
<li><a href="#">Uni</a></li>
</ul>
</li>
<li><a href="refresher3.html">Costume Hire </a> </li>
<li><a href="refresher3.html">Contact</a> </li>
</h3>
<!-- <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> -->
<!-- HTML for SEARCH BAR -->
<div>
<form id="tfnewsearch" method="get" action="http://www.google.com">
<input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton">
</form>
<div class="tfclear"></div>
</div>
</div>
<div id="content">
<?php
//connect to the server and create database.
$host = "";
$userMS = "";
$passwordMS = "";
$connection = mysql_connect($host,$userMS,$passwordMS) or die("Couldn't connect:".mysql_error());
$database = "projectDataBase";
$db = mysql_select_db($database,$connection) or die("Couldn't select database");
//build the table to show the records.
echo("<table>");
echo("<tr>
<th>Product ID</th>
<th>Product Name</th>
<th>Product Image</th>
<th>Age</th>
<th>Stauts</th>
<th>Price</th>
</tr>");
//database query to show all the records.
$selectString = "SELECT
Product.Product_ID,
Product.Product_Name,
Product.Image,
Gender.Gender_Description,
Category.Description,
`Status`.Availability,
Product.Price,
Age.Age_Description
FROM
Product
JOIN
Age ON Product.Age_ID = Age.Age_ID
JOIN
Category ON Product.Category_ID = Category.Category_ID
JOIN
Gender ON Product.Gender_ID = Gender.Gender_ID
JOIN
`Status` ON Product.Status_ID = `Status`.Status_ID
";
$result = mysql_query($selectString);
while ($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the Product image.
if($index == "Image")
{
echo("<td><img src = $value alt = 'Image'></td>");
}
else{
echo("<td>$value</td>");
}
$self = htmlentities($_SERVER['PHP_SELF']);
echo("<form action = '$self' method='POST'>");
echo "<input type='hidden' name='athID' value='$row[Product_ID]' >";
/*echo("<td><input type='submit' name='delete' value = 'Delete'/></td>");*/
echo ("</form>");
echo("</tr>");
echo("</tr>");
}
echo("</table>");
/*
echo("<table>");
echo("<tr>
<th>Country Code</th>
<th>Country Name</th>
<th>Population</th>
<th>Image</th>
</tr>");
$selectString = "SELECT * from tblCountries";
$result = mysql_query($selectString);
while($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the country image.
if($index == "flag_image")
{
echo("<td><img src = $value alt = 'countryImage'></td>");
}
else{
echo("<td>$value</td>");
}
echo("</tr>");
}
echo("</table>");
*/
mysql_free_result($result);
?>
</div>
<footer>Copyright © Hucos Pucos Shop</footer>
</div>
<div id="container">
<img src ="banner.jpg" width="400" height="100"/>
<div id="menu">
<h3>
<li><a href="refresher.php">Home </a> </li>
<li><a href="refresher2.html">About </a> </li>
<li><a href="refresher3.html">Category </a>
<ul> <li><a href="Boys.php">Boys</a></li>
<li><a href="Girls.php">Girls</a></li>
<li><a href="#">Uni</a></li>
</ul>
</li>
<li><a href="refresher3.html">Costume Hire </a> </li>
<li><a href="refresher3.html">Contact</a> </li>
</h3>
<!-- <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> -->
<!-- HTML for SEARCH BAR -->
<div>
<form id="tfnewsearch" method="get" action="http://www.google.com">
<input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton">
</form>
<div class="tfclear"></div>
</div>
</div>
<div id="content">
<?php
//connect to the server and create database.
$host = "";
$userMS = "";
$passwordMS = "";
$connection = mysql_connect($host,$userMS,$passwordMS) or die("Couldn't connect:".mysql_error());
$database = "projectDataBase";
$db = mysql_select_db($database,$connection) or die("Couldn't select database");
//build the table to show the records.
echo("<table>");
echo("<tr>
<th>Product ID</th>
<th>Product Name</th>
<th>Product Image</th>
<th>Age</th>
<th>Stauts</th>
<th>Price</th>
</tr>");
//database query to show all the records.
$selectString = "SELECT
Product.Product_ID,
Product.Product_Name,
Product.Image,
Gender.Gender_Description,
Category.Description,
`Status`.Availability,
Product.Price,
Age.Age_Description
FROM
Product
JOIN
Age ON Product.Age_ID = Age.Age_ID
JOIN
Category ON Product.Category_ID = Category.Category_ID
JOIN
Gender ON Product.Gender_ID = Gender.Gender_ID
JOIN
`Status` ON Product.Status_ID = `Status`.Status_ID
";
$result = mysql_query($selectString);
while ($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the Product image.
if($index == "Image")
{
echo("<td><img src = $value alt = 'Image'></td>");
}
else{
echo("<td>$value</td>");
}
$self = htmlentities($_SERVER['PHP_SELF']);
echo("<form action = '$self' method='POST'>");
echo "<input type='hidden' name='athID' value='$row[Product_ID]' >";
/*echo("<td><input type='submit' name='delete' value = 'Delete'/></td>");*/
echo ("</form>");
echo("</tr>");
echo("</tr>");
}
echo("</table>");
/*
echo("<table>");
echo("<tr>
<th>Country Code</th>
<th>Country Name</th>
<th>Population</th>
<th>Image</th>
</tr>");
$selectString = "SELECT * from tblCountries";
$result = mysql_query($selectString);
while($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the country image.
if($index == "flag_image")
{
echo("<td><img src = $value alt = 'countryImage'></td>");
}
else{
echo("<td>$value</td>");
}
echo("</tr>");
}
echo("</table>");
*/
mysql_free_result($result);
?>
</div>
<footer>Copyright © Hucos Pucos Shop</footer>
</div>
使现代化
用我下面的例子。。。所以
<div id="container">
<img src ="banner.jpg" width="400" height="100"/>
<div id="menu">
<h3>
<li><a href="refresher.php">Home </a> </li>
<li><a href="refresher2.html">About </a> </li>
<li><a href="refresher3.html">Category </a>
<ul> <li><a href="Boys.php">Boys</a></li>
<li><a href="Girls.php">Girls</a></li>
<li><a href="#">Uni</a></li>
</ul>
</li>
<li><a href="refresher3.html">Costume Hire </a> </li>
<li><a href="refresher3.html">Contact</a> </li>
</h3>
<!-- <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> -->
<!-- HTML for SEARCH BAR -->
<div>
<form id="tfnewsearch" method="get" action="http://www.google.com">
<input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton">
</form>
<div class="tfclear"></div>
</div>
</div>
<div id="content">
<?php
//connect to the server and create database.
$host = "";
$userMS = "";
$passwordMS = "";
$connection = mysql_connect($host,$userMS,$passwordMS) or die("Couldn't connect:".mysql_error());
$database = "projectDataBase";
$db = mysql_select_db($database,$connection) or die("Couldn't select database");
//build the table to show the records.
echo("<table>");
echo("<tr>
<th>Product ID</th>
<th>Product Name</th>
<th>Product Image</th>
<th>Age</th>
<th>Stauts</th>
<th>Price</th>
</tr>");
//database query to show all the records.
$selectString = "SELECT
Product.Product_ID,
Product.Product_Name,
Product.Image,
Gender.Gender_Description,
Category.Description,
`Status`.Availability,
Product.Price,
Age.Age_Description
FROM
Product
JOIN
Age ON Product.Age_ID = Age.Age_ID
JOIN
Category ON Product.Category_ID = Category.Category_ID
JOIN
Gender ON Product.Gender_ID = Gender.Gender_ID
JOIN
`Status` ON Product.Status_ID = `Status`.Status_ID
";
$result = mysql_query($selectString);
while ($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the Product image.
if($index == "Image")
{
echo("<td><img src = $value alt = 'Image'></td>");
}
else{
echo("<td>$value</td>");
}
$self = htmlentities($_SERVER['PHP_SELF']);
echo("<form action = '$self' method='POST'>");
echo "<input type='hidden' name='athID' value='$row[Product_ID]' >";
/*echo("<td><input type='submit' name='delete' value = 'Delete'/></td>");*/
echo ("</form>");
echo("</tr>");
echo("</tr>");
}
echo("</table>");
/*
echo("<table>");
echo("<tr>
<th>Country Code</th>
<th>Country Name</th>
<th>Population</th>
<th>Image</th>
</tr>");
$selectString = "SELECT * from tblCountries";
$result = mysql_query($selectString);
while($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the country image.
if($index == "flag_image")
{
echo("<td><img src = $value alt = 'countryImage'></td>");
}
else{
echo("<td>$value</td>");
}
echo("</tr>");
}
echo("</table>");
*/
mysql_free_result($result);
?>
</div>
<footer>Copyright © Hucos Pucos Shop</footer>
</div>
echo '<td><img src="data:image/jpeg;base64,'.base64_encode($value).'" alt="Image" />';
echo';
您可以将其直接拖放到代码中。我不知道如何使它比那更容易。请单击此答案左侧的复选标记。并单击向上箭头。谢谢
<div id="container">
<img src ="banner.jpg" width="400" height="100"/>
<div id="menu">
<h3>
<li><a href="refresher.php">Home </a> </li>
<li><a href="refresher2.html">About </a> </li>
<li><a href="refresher3.html">Category </a>
<ul> <li><a href="Boys.php">Boys</a></li>
<li><a href="Girls.php">Girls</a></li>
<li><a href="#">Uni</a></li>
</ul>
</li>
<li><a href="refresher3.html">Costume Hire </a> </li>
<li><a href="refresher3.html">Contact</a> </li>
</h3>
<!-- <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> -->
<!-- HTML for SEARCH BAR -->
<div>
<form id="tfnewsearch" method="get" action="http://www.google.com">
<input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton">
</form>
<div class="tfclear"></div>
</div>
</div>
<div id="content">
<?php
//connect to the server and create database.
$host = "";
$userMS = "";
$passwordMS = "";
$connection = mysql_connect($host,$userMS,$passwordMS) or die("Couldn't connect:".mysql_error());
$database = "projectDataBase";
$db = mysql_select_db($database,$connection) or die("Couldn't select database");
//build the table to show the records.
echo("<table>");
echo("<tr>
<th>Product ID</th>
<th>Product Name</th>
<th>Product Image</th>
<th>Age</th>
<th>Stauts</th>
<th>Price</th>
</tr>");
//database query to show all the records.
$selectString = "SELECT
Product.Product_ID,
Product.Product_Name,
Product.Image,
Gender.Gender_Description,
Category.Description,
`Status`.Availability,
Product.Price,
Age.Age_Description
FROM
Product
JOIN
Age ON Product.Age_ID = Age.Age_ID
JOIN
Category ON Product.Category_ID = Category.Category_ID
JOIN
Gender ON Product.Gender_ID = Gender.Gender_ID
JOIN
`Status` ON Product.Status_ID = `Status`.Status_ID
";
$result = mysql_query($selectString);
while ($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the Product image.
if($index == "Image")
{
echo("<td><img src = $value alt = 'Image'></td>");
}
else{
echo("<td>$value</td>");
}
$self = htmlentities($_SERVER['PHP_SELF']);
echo("<form action = '$self' method='POST'>");
echo "<input type='hidden' name='athID' value='$row[Product_ID]' >";
/*echo("<td><input type='submit' name='delete' value = 'Delete'/></td>");*/
echo ("</form>");
echo("</tr>");
echo("</tr>");
}
echo("</table>");
/*
echo("<table>");
echo("<tr>
<th>Country Code</th>
<th>Country Name</th>
<th>Population</th>
<th>Image</th>
</tr>");
$selectString = "SELECT * from tblCountries";
$result = mysql_query($selectString);
while($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the country image.
if($index == "flag_image")
{
echo("<td><img src = $value alt = 'countryImage'></td>");
}
else{
echo("<td>$value</td>");
}
echo("</tr>");
}
echo("</table>");
*/
mysql_free_result($result);
?>
</div>
<footer>Copyright © Hucos Pucos Shop</footer>
</div>
请检查此链接:-您遇到了什么错误?我不清楚,但我试图从产品表blob图像中获取什么内容页面可以从数据库中读取,但显示类似符号的图像除外�JFIF��x�x��ÿá�泽西夫��嗯�*�����������J��������Q�������Q������tQ������T�����† ��±ÿÛ�C� ÿÛ�CÿÀ�_"�ÿÄ����������� 在网页上!!似乎你的英语技能正在妨碍你。我发布的链接和我发布的代码都是如何在PHP中显示blob的示例。你能看看我的代码和数据库以更好地理解吗,你的代码不适合我好的,我会编辑我的答案,但你没有使用我告诉你使用的代码。
<div id="container">
<img src ="banner.jpg" width="400" height="100"/>
<div id="menu">
<h3>
<li><a href="refresher.php">Home </a> </li>
<li><a href="refresher2.html">About </a> </li>
<li><a href="refresher3.html">Category </a>
<ul> <li><a href="Boys.php">Boys</a></li>
<li><a href="Girls.php">Girls</a></li>
<li><a href="#">Uni</a></li>
</ul>
</li>
<li><a href="refresher3.html">Costume Hire </a> </li>
<li><a href="refresher3.html">Contact</a> </li>
</h3>
<!-- <meta name="ROBOTS" content="NOINDEX, NOFOLLOW" /> -->
<!-- HTML for SEARCH BAR -->
<div>
<form id="tfnewsearch" method="get" action="http://www.google.com">
<input type="text" class="tftextinput" name="q" size="21" maxlength="120"><input type="submit" value="search" class="tfbutton">
</form>
<div class="tfclear"></div>
</div>
</div>
<div id="content">
<?php
//connect to the server and create database.
$host = "";
$userMS = "";
$passwordMS = "";
$connection = mysql_connect($host,$userMS,$passwordMS) or die("Couldn't connect:".mysql_error());
$database = "projectDataBase";
$db = mysql_select_db($database,$connection) or die("Couldn't select database");
//build the table to show the records.
echo("<table>");
echo("<tr>
<th>Product ID</th>
<th>Product Name</th>
<th>Product Image</th>
<th>Age</th>
<th>Stauts</th>
<th>Price</th>
</tr>");
//database query to show all the records.
$selectString = "SELECT
Product.Product_ID,
Product.Product_Name,
Product.Image,
Gender.Gender_Description,
Category.Description,
`Status`.Availability,
Product.Price,
Age.Age_Description
FROM
Product
JOIN
Age ON Product.Age_ID = Age.Age_ID
JOIN
Category ON Product.Category_ID = Category.Category_ID
JOIN
Gender ON Product.Gender_ID = Gender.Gender_ID
JOIN
`Status` ON Product.Status_ID = `Status`.Status_ID
";
$result = mysql_query($selectString);
while ($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the Product image.
if($index == "Image")
{
echo("<td><img src = $value alt = 'Image'></td>");
}
else{
echo("<td>$value</td>");
}
$self = htmlentities($_SERVER['PHP_SELF']);
echo("<form action = '$self' method='POST'>");
echo "<input type='hidden' name='athID' value='$row[Product_ID]' >";
/*echo("<td><input type='submit' name='delete' value = 'Delete'/></td>");*/
echo ("</form>");
echo("</tr>");
echo("</tr>");
}
echo("</table>");
/*
echo("<table>");
echo("<tr>
<th>Country Code</th>
<th>Country Name</th>
<th>Population</th>
<th>Image</th>
</tr>");
$selectString = "SELECT * from tblCountries";
$result = mysql_query($selectString);
while($row = mysql_fetch_assoc($result))
{
echo("<tr>");
foreach($row as $index=>$value)
//to show the country image.
if($index == "flag_image")
{
echo("<td><img src = $value alt = 'countryImage'></td>");
}
else{
echo("<td>$value</td>");
}
echo("</tr>");
}
echo("</table>");
*/
mysql_free_result($result);
?>
</div>
<footer>Copyright © Hucos Pucos Shop</footer>
</div>