第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何從數(shù)據(jù)庫中檢索和顯示圖像?

如何從數(shù)據(jù)庫中檢索和顯示圖像?

PHP
富國滬深 2021-10-15 15:19:30
我有一個表單,我需要在其中附加圖像文件并上傳到數(shù)據(jù)庫,我可以將其插入到數(shù)據(jù)庫中。但是我無法從數(shù)據(jù)庫中檢索圖像來顯示它。如何從數(shù)據(jù)庫中獲取圖像并顯示?form2.php: <form action="insert2.php" method="GET" enctype="multipart/form-data">      <div class="container">                    <div class="row">                        <h2>3. Description of Item(s) </h2>                    </div>                <div class="col-xs-12">                    <div class="styled-input wide">                        <textarea name="description" required /></textarea>                    </div>    // this is the file attachment where it allows to select file from computer.                    <div>                      <label>Attachment:</label><input type='file' name='img' ><br>                    </div>                </div>    </form>插入2.php:    $con= mysqli_connect('127.0.0.1','root','');    if(!$con)    {        echo 'Not Connected To Server';    }    if(!mysqli_select_db($con,'satsform1'))    {        echo 'Database Not Selected';    }    $description = $_GET['description'];    $image = $_GET['img'];//insert image to database.    $sql = "INSERT INTO handover (description,image)     VALUES ('$description','$image')";    if(!mysqli_query($con,$sql))    {        echo 'Not Submitted';    }    else    {        echo 'Submitted';    }    header("refresh:2; url=selection.php")?>
查看完整描述

2 回答

?
楊__羊羊

TA貢獻(xiàn)1943條經(jīng)驗 獲得超7個贊

這是您可以使用的示例腳本:


<?php

$con= mysqli_connect('127.0.0.1','root','');


$query = "SELECT * FROM handover ORDER BY ID";


$stmt = $con->prepare($query);

$stmt->execute();

$result = $stmt->get_result();

$stmt->close();

while($obj = $result->fetch_object()) {

echo($obj->ID.":   <img src='".$obj->image."' alt='IMG-".$obj->ID."' height='150' width='150'><br>");

echo($obj->description);

}

?>

將此代碼綁定到您的form2.php或media.php應(yīng)該工作。如果您想要此代碼中的其他內(nèi)容,請隨時對其進(jìn)行編輯。


查看完整回答
反對 回復(fù) 2021-10-15
  • 2 回答
  • 0 關(guān)注
  • 121 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號