I tried to display image from database,
- image in directory
-
path in database
require_once "Connection.php"; class DisplayDataImageProfile { function showImageProfile(){ $connection = new Connection(); $conn = $connection->getConnection(); $id = $_GET['id']; try{ $sqlDisplay = "SELECT photo FROM frofile WHERE id =$id"; $getImage = $conn->prepare($sqlDisplay); $getImage->execute(); $getImage->fetchAll(PDO::FETCH_ASSOC); foreach($getImage as $data){ header('Content-type: image/jpg'); // echo "<img src='$data'>"; echo $data; } }catch (PDOException $e){ echo "Error : " + $e->getMessage(); } }}
after that i call in html page like this :
<img src="DisplayDataImageProfile .php?id=3" align="center" />
i got problem that image cannot retrieve from database using path. other case on webpage the image something like broken image displayed.
for currently i just display one image.