[英]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.";
?>
i want to add and update database having multiple images in a single column.我想添加和更新在单个列中包含多个图像的数据库。 i want to add and update database having multiple images in a single column我想添加和更新在单个列中包含多个图像的数据库
$res=$data['imagess']; $res=$data['images']; Are you sure its imagess not images here?你确定它的图像不是这里的图像吗?
$rest=explode(" ",$res); $rest=explode(" ",$res); Some of the file name includes spaces in it so using space to explode is not a good idea.一些文件名中包含空格,因此使用空格分解不是一个好主意。 You can use some specific set of characters like: $rest=explode("|||",$res);您可以使用一些特定的字符集,例如:$rest=explode("|||",$res); to divide the filenames.分割文件名。
But why would you have multiple images in a single database column.但是为什么在单个数据库列中有多个图像。 As far as I have understood, you wanted to have multiple images for a single parameter.据我了解,您想为单个参数设置多个图像。 Try having two database tables: one for all details and other for images only.尝试使用两个数据库表:一个用于所有详细信息,另一个仅用于图像。 For example:例如:
Table 1: id title description表一:id标题说明
Table 2: id category-id filename表 2:id category-id 文件名
Here category-id is the id to table 1 used as foreign key.这里的 category-id 是用作外键的表 1 的 id。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.