i have a table t1 have two column id and name i want to insert files names in one column
<input type="file" name="files[]" multiple></br>
<input type="submit" name="submit" value="ADD">
table
id | name
1 | e1.jpg, e2.jpg, ....
i tried
if (isset($_POST['submit'])) {
$output = '';
if(is_array($_FILES))
{
foreach ($_FILES['files']['name'] as $name => $value)
{
$file_name = explode(".", $_FILES['files']['name'][$name]);
$allowed_ext = array("jpg", "jpeg", "png", "gif");
if(in_array($file_name[1], $allowed_ext))
{
$new_name = md5(rand()) . '.' . $file_name[1];
$sourcePath = $_FILES['files']['tmp_name'][$name];
$targetPath = "picem/".$new_name;
$sql = "INSERT INTO phem (userid, username, img, date) VALUES
('$id_user','$user','{$targetPath}','$myDate')";
$image = mysqli_query($conn,$sql);
if(move_uploaded_file($sourcePath, $targetPath))
{
}
}
}
}
}
but this code will insert each file in a row