I am trying to delete files from a folder on my server using unlink. I know how to delete a single file but in this case i need to delete all files which share a common 'name' . Below is my code
$sql = "SELECT *
FROM photos
WHERE photo_group = '$_POST[name]'";
//execute the sql statement
$result = mysql_query($sql, $conn)or die(mysql_error());
$section = $row['section'];
$photo_group = $row['photo_group'];
$title=$row['title'];
$filename[]=$row['filename'];
$id = $row['id'];
$path = '/srv/www/htdocs/webdev/caspi/photo_uploads/';
$unlink = unlink($path . $filename);
if ($unlink) {$display_block .= "Those files been deleted .";} else {$display_block = "There is a problem ! Unable to delete.";}
Now the sql will bring out more than one record and i want to delete from the server all that it brings out. I tried using [] array but this is not allowed.
Can anyone shed any light onto this please??
Thanks