Reputation: 211
I have a database which contain blob images. I want to display them in a webpage. I'm using the following php code to get the image. But it didn't work properly.
<?php
while($row=mysql_fetch_array($results))
{?>
<tr>
<td><img src="<?php echo $row["image"]?>" height="200" width="250"></td>
</tr>
<?php
}?>
With this code I'm getting a webpage like this.
Where I have to do the correction to my code.
Upvotes: 0
Views: 553
Reputation: 843
try to convert it to base64:
<img src="data:image/jpeg;base64,<?php echo base64_encode($row['image']); ?>" height="200" width="250">
Note that you should also store the image type in your DB, so you can dynamically change "data:image/jpeg".
Upvotes: 2