我很難從資料庫中獲取影像。我只能獲取影像的 id,但實際的影像檔案不能。這是我在 display.php 中嘗試獲取影像的代碼。
$sql="Select * from tblcenter";
$result=mysqli_query($con,$sql);
$number=1;
while($row=mysqli_fetch_assoc($result)){
$id=$row['id'];
$img_id = $row['img_id'];
$name=$row['name'];
$mobile=$row['mobile'];
$email=$row['email'];
$address=$row['address'];
$table.='
<tr>
<td scope="row">'.$number.'</th>
<td><img src = "data:uploads/;base64,'.base64_encode($row['img_id']).'"style="width: 100px;
height: 100px"></td>
<td>'.$name.'</td>
<td>'.$mobile.'</td>
<td>'.$email.'</td>
<td>'.$address.'</td>
<td>
<button onclick="GetDetails('.$id.')">Update</button>
<button onclick="DeleteUser('.$id.')">Delete</button>
</td>
</tr>';
$number ;
}
這是我當前代碼的結果
這是影像的資料庫/表
uj5u.com熱心網友回復:
$sql="Select t.*,i.img_name from tblcenter t JOIN images i ON t.img_id = i.id";
$result=mysqli_query($con,$sql);
$number=1;
while($row=mysqli_fetch_assoc($result)){
$id=$row['id'];
$img_name = $row['img_name'];
$name=$row['name'];
$mobile=$row['mobile'];
$email=$row['email'];
$address=$row['address'];
$table.='
<tr>
<td scope="row">'.$number.'</th>
<td><img src = "/images/'. $row['img_name'] . '" style="width: 100px;
height: 100px"></td>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/449421.html
上一篇:Ajax:在沒有php的情況下將表單資料附加到json檔案
下一篇:NoReverseMatch未找到帶有引數'('',)'的'save-post'的反向。嘗試了1種模式:['save/(?P<
