How do i get a file as an image from a database using php?I've tried this however all I get is the name of the image not the actual image. Is there any specific syntax that must be used? Also the Image type in the database is of type BLOB so it should store the image .
<!DOCTYPE html>
<html>
<body>
<?php
$servername = "localhost";
$username = "WebAssignment";
$password ="qwer12";
$dbname = "webassigment";
// Create connection
$conn = new mysqli($servername, $username,$password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT Food_Name, Food_Price,Food_Category, Image FROM menu";
$result = $conn->query($sql);
$array = array();
while($row =$result->fetch_assoc()){
// add each row returned into an array
$array[] = $row;
}
?>
<h2>Starters</h2>
<?php
for($i=0;$i<sizeof($array);$i++) {
if($array[$i]["Food_Category"]=="starters"){
echo $array[$i]["Food_Name"]. " " . $array[$i]["Food_Price"]. "<br>" . $array[$i]["lastname"]. "<br>".$array[$i]["Image"]."<br>";
}
}
?>
<h2>Burgers</h2>
<?php
for($i=0;$i<sizeof($array);$i++) {
if($array[$i]["Food_Category"]=="burgers"){
echo $array[$i]["Food_Name"]. " " . $array[$i]["Food_Price"]. "<br>" . $array[$i]["lastname"]. "<br>".$array[$i]["Image"]."<br>";
}
}
?>
<h2>Desserts</h2>
<?php
for($i=0;$i<sizeof($array);$i++) {
if($array[$i]["Food_Category"]=="desserts"){
echo $array[$i]["Food_Name"]. " " . $array[$i]["Food_Price"]. "<br>" . $array[$i]["lastname"]. "<br>".$array[$i]["Image"]."<br>"; }
}
?>
<h2>Drinks</h2>
<?php
for($i=0;$i<sizeof($array);$i++) {
if($array[$i]["Food_Category"]=="drinks"){
echo $array[$i]["Food_Name"]. " " . $array[$i]["Food_Price"]. "<br>" . $array[$i]["lastname"]. "<br>".$array[$i]["Image"]."<br>"; }
}
$conn->close();
?>
</body>
</html>