0

http://www.myu2sig.com/checkit.php

The below code is from the above URL, what I would like to have done is have some code added that takes the (Delete) beside each name and turn it in to a clickable link that deletes ONLY the mage it's attached to. So if delete is hit for image A it leaves images B and C alone (each image should delete independantly of the others).

So, here's my question... would someone please modify the below code for me to achieve this ?

Ideally when the Deleter link is clicked for the associated image the page would refresh and show the remaining images. Like right now there's three images, so if I delete one the page would refresh and show the remaining two.

<?php

echo '<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>';

$link = mysql_connect('localhost', 'USER', 'PASS');

mysql_select_db('DBASE', $link);

if ($handle = opendir('DIRECTORY_PATH')) {
    while (false !== ($file = readdir($handle))) {
			$file = str_replace(".png", "", $file);
$ssql = "QUERY";
$sresult = mysql_query($ssql);
if(!mysql_num_rows($sresult)){
        if ($file != "." && $file != "..") {
            echo $file, ' (Delete)<br />';
			echo '<img src="BASE_URL', $file, '.png"><br /><br />';
        }
}
    }
    closedir($handle);
}

echo '</body></html>';

?>

Edited by MoreBloodWine: n/a

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by diafol
0

You have to create one mysql table where you can store which user have which image.
Then on delete link you can delete from table.

Edited by vibhaJ: n/a

0

You have to create one mysql table where you can store which user have which image.
Then on delete link you can delete from table.

Nothing from the DB is to be deleted, the images shown along with names are images from a folder with no corresponding DB info. It's these images I want to delete one by one as previously stated.

0

Making it easier, you could have an ajax delete, which would take off the item from the page and then delete the physical file from the folder without page refresh.

OR

Have checkboxes by each and one big delete button at the bottom of the page, so you can delete all the offending pictures, at the same time.

You say you need to delete them one at a time, so perhaps this isn't what you're after.

You mention that the images to be deleted have no corresponding DB info, would not a loop over the folder, getting the filenames, checking them against the DB and deleting 'no result' items be easier?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.