How to display an BLOB image stored in MySql database?

前端 未结 4 2147
孤城傲影
孤城傲影 2020-11-30 11:56

I am trying to display the last 5 images uploaded to my \"store\" table in MySql. I\'m a complete noob to PHP and databases and i\'ve been reading a lot on how to do this bu

4条回答
  •  醉话见心
    2020-11-30 12:38

    I try the first approach with header('content-type: image/jpeg'); but end up with image not shown. After a few google through website I found the solution which I can display image from database to my page

    try this:

    mysql_connect("localhost","root","")or die("Cannot connect to database"); //keep your db name
    mysql_select_db("example_db") or die("Cannot select database");
    $sql = "SELECT * FROM `article` where `id` = 56"; // manipulate id ok 
    $sth = mysql_query($sql);
    $result=mysql_fetch_array($sth);
    // this is code to display 
    echo ''
    

提交回复
热议问题