Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['submit']))
  3. {
  4.     if(isset($_POST['selection']) && is_array($_POST['selection']))
  5.     {
  6.         if(count((array) $_POST['selection']) == 1)
  7.         {
  8.             $query_build = '= ' . $_POST['selection'][0];
  9.         }
  10.         else
  11.         {
  12.             $query_build = 'IN (' . implode(', ', $_POST['selection']) . ')';
  13.         }
  14.  
  15.         //$query = mysql_query("DELETE FROM table WHERE id $query_build");
  16.         echo "DELETE FROM table WHERE id $query_build";
  17.     }
  18.     else
  19.     {
  20.         echo 'You must select 1';
  21.     }
  22. }
  23. ?>
  24.  
  25. <form action="" method="post">
  26.     <input type="checkbox" name="selection[]" value="1" /> 1
  27.     <input type="checkbox" name="selection[]" value="2" /> 2
  28.     <input type="checkbox" name="selection[]" value="3" /> 3
  29.     <input type="submit" name="submit" value="delete" />
  30. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement