I want to update single image from database . Multiple images are stored in database with comma separate values.
----------
Table Name
model_final
id images gender
10 Koala.jpg,Tulips.jpg,Chrysanthemum.jpg,Desert.jpg,Jellyfish.jpg male
On request of Edit i want to edit just one image. Example : i had store all images separately in database using explode function the are shown in table. -- on click of Koala.jpg i want to update only that image so how to i check it from database.
if(isset($_GET['edit']))
{
$editId = $_GET['edit'];
$res = $conn->query("select * from model_final where gender='0' and id='$editId'");
$row = mysqli_fetch_assoc($res);
$image1 = explode(',',$row['images']);
print_r($image1);
}
Print result is ,
Array ( [0] => Koala.jpg [1] => Tulips.jpg [2] => Chrysanthemum.jpg [3] => Desert.jpg [4] => Jellyfish.jpg )
Now i want to update only koala.jpg which on 0th position in image column so how can i check it through query and how can i update only that image.
Please let me know if any other imformation is needed.
EDIT :
I have shown scenario in photo. User can upload upto 100 images so i have to store images in database with comma separeted manner .
EDIT 2:
Table structure of 'images_female'
id image1 image2 image3 image_user_id
1 Koala.jpg Tulips.jpg Chrysanthemum.jpg 56
if(isset($_GET['edit']) && isset($_GET['name']))
{
$editId = $_GET['edit'];
$res = $conn->query("select * from model_final where gender='0' and id='$editId'");
$row = mysqli_fetch_assoc($res);
$image1 = explode(',',$row['images']);
$image1_0 = $image1['0'];
$image1_1 = $image1['1'];
$image1_2 = $image1['2'];
$image1_3 = $image1['3'];
$image1_4 = $image1['4'];
$image1_5 = $image1['5'];
$image1_6 = $image1['6'];
$insert_data_images = $conn -> query("insert into images_female (image1,image2,image3,image4,image5,image_user_id) values
('$image1_0','$image1_1','$image1_2','$image1_3','$image1_4','$editId')");
$update_data_images = $conn -> query("update images_female set image where image_user_id='$editId'");
}
// i'm confuse in update query of set data how can i set image on that specific field.