I am trying to display an image coming from the database and I was not able to display the image .but its showing like this user-1.jpg
Please see my code can one guide me how to display the image.
$sqlimage = "SELECT image FROM userdetail where `id` = $id1";
$imageresult1 = mysql_query($sqlimage);
while($rows = mysql_fetch_assoc($imageresult1))
{
$image = $rows['image'];
print $image;
}
php to display the images from database. We will use MySQL select query to retrieve the image in database. Copy the below code and paste it in between <div class="img-box"> ... </div> of show.
Check whether the user selects an image file to upload. Retrieve the content of image file by the tmp_name using PHP file_get_contents() function. Insert the binary content of the image in the database using PHP and MySQL. Show the image uploading status to the user.
php $id = $_GET['id']; // do some validation here to ensure id is safe $link = mysql_connect("localhost", "root", ""); mysql_select_db("dvddb"); $sql = "SELECT imageColumn FROM Tablename WHERE id=$id"; $result = mysql_query("$sql"); $row = mysql_fetch_assoc($result); mysql_close($link); header("Content-type: image/jpeg ...
Displaying an image from MySql Db.
$db = mysqli_connect("localhost","root","","DbName");
$sql = "SELECT * FROM products WHERE id = $id";
$sth = $db->query($sql);
$result=mysqli_fetch_array($sth);
echo '<img src="data:image/jpeg;base64,'.base64_encode( $result['image'] ).'"/>';
For example if you use this code , you can load image from db (mysql) and display it in php5 ;)
<?php
$con =mysql_connect("localhost", "root" , "");
$sdb= mysql_select_db("my_database",$con);
$sql = "SELECT * FROM `news` WHERE 1";
$mq = mysql_query($sql) or die ("not working query");
$row = mysql_fetch_array($mq) or die("line 44 not working");
$s=$row['photo'];
echo $row['photo'];
echo '<img src="'.$s.'" alt="HTML5 Icon" style="width:128px;height:128px">';
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With