Display image from sql

前端 未结 5 642
星月不相逢
星月不相逢 2021-01-22 13:52

I\'ve create a table where I\'ve saved images through \"BLOB\". I need to show those images along with other items. But I don\'t know how to show those images together in the sa

5条回答
  •  忘掉有多难
    2021-01-22 14:25

    As other people mentioned, storing the images in the database is usually a bad idea.

    Images are not transmitted in the same HTTP response with another page data.

    To show images from the database, you would need to implement a script which, given the item id, would read the field and send the image's binary data; and provide the path to the script in your form's :

    while($row = mysql_fetch_array($display_query)){
        print "".$row['itemid']."".$row['description']."";
        print "₹".$row['cost']."";
        print "";
    
    }
    

    image.php is another script which outputs the value of image_blob given the eportal.id. You would also need to provide correct size and mime type in the headers.

    You better just store the images in a file (accessible by the web server) and store the path fo the file in the database.

提交回复
热议问题