繁体   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