Need help with only needing to delete images uploaded by ID

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Shinmeiryu
Forum Commoner
Posts: 29
Joined: Wed Nov 13, 2002 2:57 am

Need help with only needing to delete images uploaded by ID

Post by Shinmeiryu »

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?

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>.';
User avatar
Shinmeiryu
Forum Commoner
Posts: 29
Joined: Wed Nov 13, 2002 2:57 am

Post by Shinmeiryu »

Also wondering, would this also have to something to do with code on how I uploaded the images which might affect whether I can delete them according to the batch of images submitted by its ID?

Because the imagefile field always only display the value "array" and never the file names.
Post Reply