dongyu7074 2013-09-05 09:32
浏览 36
已采纳

如何在单个HTTP响应中使用PHP从Mysql服务4个图像(Blob)?

I am trying to display 4 images using PHP and MySQL database. I have to display the 4 images as rows.

I use the table cars with fields (id_car, car_image1, car_image2, car_image3, car_image4), with all the images being blob datatype.

$id = $_GET['id'];

$link = mysql_connect("localhost", "root", "");
mysql_select_db("cars_database");
$sql = "SELECT car_image1, car_image2, car_image3, car_image4 FROM cars WHERE id_car='$id'";
$result = mysql_query("$sql");

mysql_close($link);
while($row=mysql_fetch_array($result))
{
    header('Content-type: image/jpeg');
    echo $row['car_image1'];
    echo $row['car_image2'];
    echo $row['car_image3'];
    echo $row['car_image4'];    
}

I can only display 1 image and not the other images. Since I am a newbie to this technology I need help.

  • 写回答

2条回答 默认 最新

  • douxi3233 2013-09-05 09:36
    关注

    That's how HTTP works (at least, current version): you cannot have a URL that points to more than one resource simultaneously. Your script needs to send one image.

    Simply, call it four times:

    <img src="/get-image.php?id=1">
    <img src="/get-image.php?id=2">
    <img src="/get-image.php?id=3">
    <img src="/get-image.php?id=4">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么