Need help with only needing to delete images uploaded by ID
Posted: Thu Jan 30, 2003 5:25 pm
I can display and unlink the files from the directory with checkboxes, but I only want to show the files that were submitted according to each ID. For some reason calling up the specific array still won't come up as it opens up all the files from that directory to display on checkboxes.
Basically, I need it to only display the images submitted (uploaded) to that particular ID that I'm looking to delete and it seems mysql_fetch_array is not the solution. When I do try to call it up, the text for the checkboxes only name itself as "Array" and not as the files in the directory.
Is there a way to call only the specific array of files up uploaded within that ID?
Basically, I need it to only display the images submitted (uploaded) to that particular ID that I'm looking to delete and it seems mysql_fetch_array is not the solution. When I do try to call it up, the text for the checkboxes only name itself as "Array" and not as the files in the directory.
Is there a way to call only the specific array of files up uploaded within that ID?
Code: Select all
//refer to particular imagesetID where records for imagefile are being stored
$query = "SELECT * FROM screenshots";
$result = mysql_query($query) or die('error making query');
while($row = mysql_fetch_array($result)) {
$imagesetID = $row['ID'];
$file = $row['imagefile'];
}
$path = './files/';
extract($_POST);
if($submit)
{
for($i = 0; $i < count($files); $i++)
{
unlink($path.$files[$i]);
}
echo 'These files are deleted...<p>';
}
else
{
echo '<form action="" method="post">';
echo 'Are you sure you want to delete this whole set of images?<br>';
$open = opendir($path);
while($file = readdir($open))
{
if($file != '.' && $file != '..' && !is_dir($file))
{
echo '<input type="checkbox" name="files[]" value="'.$file.'" checked>'.$file.'<br>';
}
}
echo '<input type="submit" name="submit" value="Submit">';
echo '</form>';
}
//$query = "DELETE FROM screenshots WHERE ID='$imagesetID'";
//$result = mysql_query($query) or die('error making query');
echo '<a href="index.php">Return to the main page</a>.';