Muhammad Usman Muhammad Usman - 2 months ago 7
SQL Question

image display from database in php

i want to display image from database and below is my code where empid is the value of textbox, it's showing the image name stored in database but i am not able to echo this picture. anyone can help in this regard.

<?php
include('connect.php');

$result = $db->prepare("SELECT image FROM info WHERE empid= $empid");
$result->bindParam('$empid', $empid);
$result->execute();
for($i=0; $rows = $result->fetch(); $i++){

echo $rows['image'];


}

?>

Answer

Change this line.

$result = $db->prepare("SELECT image FROM info WHERE empid= '". $empid ."'");