[英]How to display BLOB Images from database in a while loop
I've been working on these codes for 2 hours now and i can't seem to make it appear. 我已经在这些代码上工作了2个小时了,我似乎无法使它出现。 It has the right ID, but the picture doesnt show.
它具有正确的ID,但图片不显示。 i have no idea why.
我不知道为什么。
anyway, here are my codes. 无论如何,这是我的代码。
this is for showing the pic along with other stuff. 这是用于显示图片以及其他内容。
<div align="left">
<center><img src="img/compressportbanner.jpg" height="180"></center>
<table border="0" cellpadding="2px" width="600px">
<?php
$result=mysql_query("select * from inventory WHERE prod_brand = 'Compressport' AND prod_category='compression' ");
while($row=mysql_fetch_array($result)){
?>
<tr>
<td>
<?php
echo '<'.'img src="image.php?prod_id='.$row['prod_id'].'" alt="'.$row['prod_name'].'" width="250">';
?>
</td>
<td> <b><?php echo $row['prod_name']?></b><br />
<?php echo $row['prod_category']?>
<!--<?php echo $row['prod_desc']?>-->
<br>
Price:<big style="color:green">
₱ <?php echo $row['prod_price']?></big><br /><br />
<input type="button" value="Add to Cart" onclick="addtocart(<?php echo $row['prod_id']?>)" />
</td>
</tr>
<tr><td colspan="2"><hr size="1" /></td>
<?php } ?>
</table>
</div>
and here is the image.php 这是image.php
<?php
$prodID=($_GET['prod_id']);
$sql = "SELECT * FROM `inventory` where `prod_id` = ".$prodID;
$qry = mysql_query($sql);
$result=mysql_fetch_array($qry);
echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['prod_pic'] ).'"/>'
?>
How do i make it appear, im new to php and im just starting to understand it. 我如何使它出现,我是php的新手,我才刚开始了解它。
Here's what I did with your codes, i added this line of code. 这是我对您的代码所做的操作,我添加了以下代码行。
<?php echo '<img src="data:image/jpeg;base64,'.base64_encode($row['prod_pic']).'" width="250">';?>
Here are the full codes. 这是完整的代码。
<div align="left">
<center><img src="img/compressportbanner.jpg" height="180"></center>
<table border="0" cellpadding="2px" width="600px">
<?php
$result=mysql_query("select * from inventory WHERE prod_brand = 'Compressport' AND prod_category='compression' ");
while($row=mysql_fetch_array($result)){
?>
<tr>
<td>
<?php
echo '<img src="data:image/jpeg;base64,'.base64_encode($row['prod_pic']).'" width="250">';
?>
</td>
<td> <b><?php echo $row['prod_name']?></b><br />
<?php echo $row['prod_category']?>
<!--<?php echo $row['prod_desc']?>-->
<br>
Price:<big style="color:green">
₱ <?php echo $row['prod_price']?></big><br /><br />
<input type="button" value="Add to Cart" onclick="addtocart(<?php echo $row['prod_id']?>)" />
</td>
</tr>
<tr><td colspan="2"><hr size="1" /></td>
<?php } ?>
</table>
</div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.