Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在jquerymobile模板上显示存储在MySql数据库中的blob类型图像_Php_Jquery_Json_Html_Blob - Fatal编程技术网

Php 如何在jquerymobile模板上显示存储在MySql数据库中的blob类型图像

Php 如何在jquerymobile模板上显示存储在MySql数据库中的blob类型图像,php,jquery,json,html,blob,Php,Jquery,Json,Html,Blob,我有一个场景,图像应该显示在我的Jquerymobile模板中。这些图像来自MySQL数据库。图像类型是blob类型,我使用PHP检索我的数据-如下所示 <?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"] =

我有一个场景,图像应该显示在我的Jquerymobile模板中。这些图像来自MySQL数据库。图像类型是blob类型,我使用PHP检索我的数据-如下所示

    <?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);
?>
在该函数中接收到值后,我将使用以下命令将它们附加到相应的HTML字段中——

 $.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);
                    });
我能够理解图像不应该被视为JSON格式。但这怎么办呢? 在PHP中,我应该怎么做才能在页面/屏幕上显示blob图像

方法正确吗


对于这一点,我在开始时寻求帮助,但我的情况似乎有所不同。

这更多的是提供解决方案的注释,而不是“单击此处查看结果”;但是试试这个:

  • 除了图像,你还有一个有效的解决方案吗
  • 图像大吗?
    • 如果它们是图标,我会将图像数据嵌入到相同的JSON响应中(参见末尾)
    • 如果它们是照片,我会返回一个URL,并有第二个HTTP请求来下载它们。你可以附上

    我有一个(带有外部文件)的大致演示。

    感谢您的回复。那帮了大忙。。如果有一个工作示例,会更有帮助。无论如何,再次感谢你的时间。
     $.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);
                        });