if (file_exists(TEMP.'/'."$check_dir".'/'."$endofname$test".'.jpeg'))
{
echo "File : $endofname$test was made <br />";
move($new_file_destination);
$img_name = 'http:localhost/single4thenight/media/com_jomclassifieds/items/backpage/'."$check_dir".'/'."$endofname$test".'_1.jpeg, ';
$img_title = "UPDATE iutca_jomcl_adverts SET images='$img_name' WHERE title='$title'";
if ($conn->query($img_title) === TRUE)
{
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($conn);
}
}
I need to add data to a table that is existing but I want to add data to the table not erase it with the updating data
If you're trying to append (concatenate) a new value to the end of an existing row's value you will still need to use UPDATE.
It would look something like this:
UPDATE iutca_jomcl_adverts SET images = CONCAT_WS('|', images, '$img_name') WHERE title='$title'
(CONCAT_WS is "concatenate with separator")
However, that won't handle the case where the row doesn't already exist. In that case, you would need to do an
INSERT
and use MySQL'sON DUPLICATE KEY UPDATE images = CONCAT(images,'|$img_name')
(iftitle
is a unique key).