Deleting images from my gallery. Help needed.....

I have made an image upload system(with the kind help of malasho on this forum).

I have a submit form for uploading the image. I also have a php script that resizes the photo to 500px on the longest side, saves the resized image to a folder(image_files) and inserts the image path anda unique id number into a mysql table(table-images)
The script also saves a resized image at 150px on the long side to a folder named thumbs and inserts the image path and an id number that matches the one in table_images into a tablenamed image_thumbs.

I also have a script for showing these images as a gallery.

I now need a way of deleting chosen images from the gallery. They need to be deleted from both folders:image_files and thumbs and also delete the entries in both tables: table_images and image_thumbs.

This is my file delete.php file so far

[php]

Delete/Archive Images #thumbs{ width: 1300px; position: relative; top: 40px; left: 0px; } #here{ position: relative; left:50px; } div.thumb{ float: left; padding: 0px 5px 10px 5px; margin-bottom: 20px; } img.thumbnail{ padding: 0px; } .imgLabel{ text-align: center; }
 <?php include 'connect.php';?>
 
 <div id='here'> 
 <P> Chooose Images to delete: </P>
 </div>
 <BLOCKQUOTE>
<?php $q = "SELECT * FROM image_thumbs"; $t = "SELECT imagepath FROM table_images"; $i = mysql_query ($t); if($r = mysql_query($q)) { echo '
'; while($row=mysql_fetch_array($r)) { if($row2=mysql_fetch_array($i)) { echo '
', "Image", "", "
", "
{$row['name']}
", '
'; } } echo '
'; } else { echo mysql_error(); } ?>
  </BLOCKQUOTE>
  </form>
[/php]

This shows all the images in the db table image_thumbs with a checkbox beside them. I dont know what to do next.

Thanks for looking!
Glen…

I don’t like to delete things from my database so I add an Active column and then check for it first when doing a query. However look up DROP to delete things from your database.

Also look up UNLINK() as the PHP command for deleting the files.

Sponsor our Newsletter | Privacy Policy | Terms of Service