Skip to main content

Drag and Drop Delete Script using PHP

Language


Hi guys,

This is a drag and drop script using PHP. Just drag the image to the trash can to delete image from the gallery.

Hope that you will like this code.

Thank you.

Database name: drag_and_drop

Sample code:

index.php

  1. <?php
  2. include('header.php');
  3. ?>
  4. <body>
  5. <div class="row-fluid">
  6. <div class="span12">
  7. <div class="container">
  8. <div class="row">
  9. <div class="span8">
  10. <div class="alert alert-info">Drag the image to the trash Can to Delete it.</div>
  11. <?php
  12.  
  13. $result = mysql_query("SELECT * FROM image order by id");
  14. while($row=mysql_fetch_assoc($result))
  15. {
  16. echo '<div class="picture"><img class="img-rounded" src="img/'.$row['img'].'" width="128" height="128" class="pngfix" /></div>';
  17. }
  18.  
  19. ?>
  20. </div>
  21. <div class="span4">
  22. <div class="content drop-here"> <i class="icon-trash" height="100"></i> <img src="img/e.png" alt="shopping cart" class="pngfix" width="128" height="128" /> </div>
  23. </div>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </body>
  29. </html>

delete.php

  1. <?php
  2.  
  3. require "connect.php";
  4.  
  5. $img=mysql_real_escape_string(end(explode('/',$_POST['img'])));
  6. $row=mysql_fetch_assoc(mysql_query("delete FROM image WHERE img='".$img."'"));
  7.  
  8. ?>

 

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Comments

Submitted byAnonymous (not verified)on Fri, 05/17/2013 - 21:02

good job. do you know also how to delete an image using a right click and a delete menu?

Add new comment

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.