Drag and Drop Delete Script using PHP

Submitted by: 
Visitors have accessed this post 5890 times.

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:


  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
  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. }
  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>


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


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.


I've tried it, but nothing happen. what is the reason behind that?

#JM Maguigad, PHP and VB 6 System Developer/Freelance Programmer
#Contact Infos: [email protected] or 09752276378

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

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.