Hi, all.
I have faced a problem. I am begginer in PHP so I need your help!!
I have backend system where admin can delete images from database, or upload another one. There is the code I did to delete the image, but something is wrong. I have two php documents, DELETE.PHP and DELETEPRO.PHP. Could you,please help with answer what is wrong and may be gove your solution? Thanks in advance!
Deletepro.php
[php]
<?php require_once("includes/connection.php"); $id=$_GET['shopID']; $query = "SELECT imagename FROM shop WHERE ID='$id"; $result = mysql_query($query) or die('Error, query failed'); mysql_query("DELETE FROM shop WHERE ID='$id'"); while ($row = mysql_fetch_array($result)){ $file = "Images/". $row["imagename"]; } unlink ($file); mysql_close($connection); // Redirect to delete.php. header("location:delete.php"); ?>[/php]
Delete.php
[php]
Delete image
<?php $result=mysql_query("SELECT imagename FROM shop ORDER BY shopID ASC"); while($row=mysql_fetch_array($result)){ echo "Id : $row[$id]"; echo "Image: $row[imagename]
"; echo '
onclick=“return confirm(‘Are you sure you want to delete this image? \nNotice: the image will be completely gone, and will have to be re-uploaded.’);”
<?php echo ' >Delete this image'; echo ""; } mysql_close($connection); ?> [/php]