I have a scenario where images should be displayed in my Jquerymobile template. These images come from MySQL database. Image type is blob type, and I am using PHP to retrieve my data - as follows
<?php
include 'configure.php';
$qr = "SELECT * FROM food_beverage";
$res= mysql_query($qr);
$i=0;
while($row = mysql_fetch_array($res))
{
$restau_arr[$i]["fb_sno"] = $row["fb_sno"];
$restau_arr[$i]["fb_name"] = $row["fb_name"];
$restau_arr[$i]["fb_type"] = $row["fb_type"];
$restau_arr[$i]["fb_location"] = $row["fb_location"];
$restau_arr[$i]["fb_img"]= $row["fb_img"];
$restau_arr[$i]["fb_phno"]= $row["fb_phno"];
$restau_arr[$i]["fb_email"]= $row["fb_email"];
$i++;
}
header('Content-type: application/json');
echo json_encode($restau_arr);
?>
The values from database are stored in an array, and are being converted to JSON format so that I can call them using the following jquery lines -
var url = "retrieve_all.php";
$.getJSON(url, function(json) {
.......
.......
....... }
Once the values are received at this function, am appending them to respective HTML fields using -
$.each(json, function(i,v) {
var restauName = v.fb_name;
var restauLoc = v.fb_location;
var restauNum = v.fb_phno;
var restauImg = v.fb_img;
$("#restauName").html(restauName);
$("#restauLoc").html(restauLoc);
$("#restauNum").html(restauNum);
$("#restauImg").html(restauImg);
});
I am able to understand that the image should NOT be taken as a JSON format. But how can this be dealt? What should I do in PHP to get my blob image displayed on my page/screen?
Is the approach correct?
For this, I checked here for help in the beginning, but my scenario seemed to be different.