I asked a question earlier regarding retrieving a image from a database; as my query was not working properly. This is now working to some extent, as the query now works,correct image name appears and a placeholder box with a question mark in the middle where the image should be.
In my earlier post, i was directed to a number of posts, to fix the image not appearing image. I followed the posts by adding:
echo'<img src="data:image/jpeg;base64,' . base64_encode($img) . '" alt="Category_header"
width="100%" height="300px">';
To my code, however it is still now working, I know you can use a header, but i am really trying to avoid that method, unless it is the more efficient way.
This is what i am receiving at the present moment:
Code
mysqli_report(MYSQLI_REPORT_INDEX);
if (isset($_GET['rest_id'])) {
$Rest = $_GET['rest_id'];
$get_cat_img = "SELECT Cuisine_category,Category_img
FROM Rest_Category
INNER JOIN Rest_Details
ON Rest_Category.CategoryID = Rest_Details.Cat_ID
WHERE Rest_Details.Resturant_ID='$Rest'";
$results = mysqli_query($dbc, $get_cat_img) or die("query is not working");
$row=mysqli_fetch_array($results) or die ("q not working");
$img=$row['Category_img'];
echo $row['Category_img']; //shows the category_img name
// echo '<img src="'.$img.'" alt="background" style="width:100%;height:300px">';
echo'<img src="data:image/jpeg;base64,' . base64_encode($img) . '" alt="Category_header" width="100%" height="300px">';
}
mysqli_close($dbc);