I try to display an image from mysql database into my php website But the image did not display, only the image description display. Please help why is my code did not display the image correctly. Below is the script that i use to save the image into database with blob data type.
*<?php
$image = $_POST['images']['tmp_name'];
$sql = mysql_query("INSERT INTO product(image) VALUES('$image')");
if($sql){
echo "Product Registration Successful";
}
else{
echo "Product Registration Failed";
}
?>*
Below is the script that i use to display the image into the website:
*<?php
$sql = mysql_query("SELECT * FROM product");
while ($tampil = mysql_fetch_array($sql)) {
?>
<tr>
<td class="img-thumbnail"><?php echo '<img src="data:image/jpeg;base64,'.base64_encode( $tampil['image'] ).'"/>'; ?></td>
</tr>
<?php
}
?>*