简体   繁体   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.";


?>

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.

相关问题 如何将多个图像路径存储在一个数组中以将值存储在数据库中的一行中,以便为php上传多个图像 - how to store multiple image path in one array to store in database the value in a single row for multiple images uploads for php 如何从单个数据库列/数组中提取值 - How to extract values from single database column / store in array 如何将 MySQLi 准备好的语句中的单行单列存储在 PHP 变量中? - How to store a single column of a single row out of a MySQLi prepared statement in a PHP variable? 如何使用mysqli(php)获得单个数据库值? - how to get a single database value using mysqli (php)? 如何使用PHP从图像标签将图像存储在数据库中? - how to store images in database from image tag using PHP? 如何使用PHP和mySQli从MySQL数据库中的一个以上的表中选择信息,必须结合单个查询 - How to select information from more then one table in MySQL Database using PHP and mySQli, has to be combined single query 如何使用 php 从数据库中显示单个图像? - How to display single image from database using php? 使用 mysqli 来自数据库的单个结果 - Single result from database using mysqli 如何使用pdo或mysqli从同一页面的数据库(blob列)中获取图像? 的PHP - How to get images from database (blob column) on the same page using pdo or mysqli ?? PHP 如何使用 MySQLi 获取单列值? - How to get single column values using MySQLi?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM