How to make a button to delete a table row? In short, on the online entry page there is a table, customers are recorded in this table, but after all, the admin logs in to the site and selects which clients he needs to delete. Then he presses the button, and the clients that are on the page are deleted from the table and from the database. This magic button is needed ...

  • one
    Maybe on the remote from the TV there is such a button? Take a look! =) It is not a button that is deleted, but a correctly written script! - Palmervan
  • one
    @Palmervan, have you read carefully? That magic button - Gorets
  • one
    Namely, the magic button)) I focused on the statement of the question, and not on the correctness of the program statements, knowledgeable people understood ... - kiberchainik
  • 2
    @kiberchainik, "knowledgeable people" love their language. Try to use all the rules when you make a question. - Nicolas Chabanovsky

2 answers 2

Approximate option. Allows you to delete multiple users at once.

<?php if(isset($_POST['del_users']) && sizeof($_POST['del_users'])){ $result = mysql_query('delete from users where id in (' . implode(',', array_keys($_POST['del_users'])) . ')'); } ?> <form action="" method="post"> User 1: <input type="checkbox" name="del_users[1]" /> User 2: <input type="checkbox" name="del_users[2]" /> User 15: <input type="checkbox" name="del_users[15]" /> <input type="submit" value="Delete!" /> </form> 
     if(isset($_POST['del_user'])) { $result = mysql_query("DELETE FROM users where user_id = ".$_POST['del_user'].""); } 

    the button itself

     <form action="" methot="POST"> <input type="hidden" name="del_user" value="{id пользователя}" /> <input type="submit" value="удалить" /> </form> 
    • Removes, thanks for the help, but it removes the entire database, and I need to be able to choose, for example, with the help of the checkbox what I need to delete and then delete ... - kiberchainik
    • 2
      Did you have all fields entered? Probably you made a mistake when editing the code for yourself. Show your code that generates users - dogmar
    • Do you have asya or where can I contact you? - kiberchainik
    • Look at the ling code, this is what you need. - dogmar