簡體   English   中英

如何使用 php mysqli 從存儲在數據庫單列中的圖像數組中刪除和更新單個圖像?

[英]how to delete and update a single image from array of images store in a single column of database using php mysqli?

<?php //display.php//
   $con = mysqli_connect("localhost", "root", "", "ist_softtech");
 $i="";
$query="select * from single_field_tbl";
$fire=mysqli_query($con,$query);
$data=mysqli_fetch_array($fire);
$res=$data['imagess'];
$rest=explode(" ",$res);
$count=count($rest)-1;
for($i=0;$i<$count;++$i)
{
    ?>
    <img src="uploads/<?= $rest[$i]?>" height="200px" width="200px"/>
    <?php
}
       echo "<p style='color:green;font-size:26px'>Total ".$count." images found.";


?>

我想添加和更新在單個列中包含多個圖像的數據庫。 我想添加和更新在單個列中包含多個圖像的數據庫

$res=$data['images']; 你確定它的圖像不是這里的圖像嗎?

$rest=explode(" ",$res); 一些文件名中包含空格,因此使用空格分解不是一個好主意。 您可以使用一些特定的字符集,例如:$rest=explode("|||",$res); 分割文件名。

但是為什么在單個數據庫列中有多個圖像。 據我了解,您想為單個參數設置多個圖像。 嘗試使用兩個數據庫表:一個用於所有詳細信息,另一個僅用於圖像。 例如:

表一:id標題說明

表 2:id category-id 文件名

這里的 category-id 是用作外鍵的表 1 的 id。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM