Loading

Drag and Drop Delete Script using PHP

Submitted by: 
Language: 
Visitors have accessed this post 5542 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:

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

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

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: ljmmaguigad28@gmail.com or 09752276378

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th>
  • You may insert videos with [video:URL]
  • 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.