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条)

报告相同问题?